mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
Pass python files through autopep8
This commit is contained in:
parent
091ce6bcfe
commit
6f9e5d4494
18 changed files with 167 additions and 159 deletions
|
@ -58,7 +58,7 @@ def handle_exception(default_return):
|
|||
def wrapped_func(*args, **kargs):
|
||||
try:
|
||||
return func(*args, **kargs)
|
||||
except:
|
||||
except BaseException:
|
||||
# Use excepthook directly to avoid any printing to the screen
|
||||
# if someone installed an except hook.
|
||||
sys.excepthook(*sys.exc_info())
|
||||
|
|
|
@ -137,7 +137,7 @@ class App (object):
|
|||
|
||||
try:
|
||||
Common.Main.MainLoopWrapper(Gtk.main, Gtk.main_quit).run()
|
||||
except:
|
||||
except BaseException:
|
||||
raise
|
||||
else:
|
||||
self.detach()
|
||||
|
|
|
@ -409,7 +409,7 @@ class SubRange (object):
|
|||
raise ValueError(
|
||||
"need start <= stop (got %r, %r)" % (start, stop,))
|
||||
|
||||
if type(size) == type(self):
|
||||
if isinstance(size, type(self)):
|
||||
# Another SubRange, don't stack:
|
||||
start += size.start
|
||||
stop += size.start
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
"""GStreamer Debug Viewer program invocation."""
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
import sys
|
||||
|
@ -64,5 +65,6 @@ def main ():
|
|||
|
||||
GstDebugViewer.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -28,7 +28,7 @@ def system(*args, **kwargs):
|
|||
kwargs.setdefault('stdout', subprocess.PIPE)
|
||||
proc = subprocess.Popen(args, **kwargs)
|
||||
out, err = proc.communicate()
|
||||
if type(out) == bytes:
|
||||
if isinstance(out, bytes):
|
||||
out = out.decode()
|
||||
return out
|
||||
|
||||
|
@ -56,7 +56,7 @@ def main():
|
|||
try:
|
||||
if not modified_file.endswith(".py"):
|
||||
continue
|
||||
pycodestyle_errors = system('pycodestyle', '--repeat', '--ignore', 'E501,E128,W605,W503', modified_file)
|
||||
pycodestyle_errors = system('pycodestyle', '--repeat', '--ignore', 'E402,E501,E128,W605,W503', modified_file)
|
||||
if pycodestyle_errors:
|
||||
if output_message is None:
|
||||
output_message = NOT_PYCODESTYLE_COMPLIANT_MESSAGE_PRE
|
||||
|
|
|
@ -65,8 +65,7 @@ class Stats(Analyzer):
|
|||
record['scope'][k] = v
|
||||
elif v.name == 'value':
|
||||
# skip non numeric and those without min/max
|
||||
if (v.values['type'] in _NUMERIC_TYPES and
|
||||
'min' in v.values and 'max' in v.values):
|
||||
if v.values['type'] in _NUMERIC_TYPES and 'min' in v.values and 'max' in v.values:
|
||||
# TODO only for debugging
|
||||
# print("value: [%s]=%s" % (k, v))
|
||||
record['value'][k] = v
|
||||
|
@ -102,15 +101,14 @@ class Stats(Analyzer):
|
|||
# aggregate event based on class
|
||||
for sk, sv in record['scope'].items():
|
||||
# look up bin by scope (or create new)
|
||||
key = (_SCOPE_RELATED_TO[sv.values['related-to']] +
|
||||
":" + str(s.values[sk]))
|
||||
key = (_SCOPE_RELATED_TO[sv.values['related-to']] + ":" + str(s.values[sk]))
|
||||
scope = self.data.get(key)
|
||||
if not scope:
|
||||
scope = {}
|
||||
self.data[key] = scope
|
||||
for vk, vv in record['value'].items():
|
||||
# skip optional fields
|
||||
if not vk in s.values:
|
||||
if vk not in s.values:
|
||||
continue
|
||||
if not s.values.get('have-' + vk, True):
|
||||
continue
|
||||
|
@ -119,7 +117,7 @@ class Stats(Analyzer):
|
|||
data = scope.get(key)
|
||||
if not data:
|
||||
data = {'num': 0}
|
||||
if not '_FLAGS_AGGREGATED' in vv.values.get('flags', ''):
|
||||
if '_FLAGS_AGGREGATED' not in vv.values.get('flags', ''):
|
||||
data['sum'] = 0
|
||||
if 'max' in vv.values and 'min' in vv.values:
|
||||
data['min'] = int(vv.values['max'])
|
||||
|
@ -190,8 +188,8 @@ def format_ts(ts):
|
|||
|
||||
def is_time_field(f):
|
||||
# TODO: need proper units
|
||||
return (f.endswith('/time') or f.endswith('-dts') or f.endswith('-pts') or
|
||||
f.endswith('-duration'))
|
||||
return (f.endswith('/time') or f.endswith('-dts') or f.endswith('-pts')
|
||||
or f.endswith('-duration'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -82,6 +82,7 @@ _PLOT_SCRIPT_BODY = Template(
|
|||
unset multiplot
|
||||
''')
|
||||
|
||||
|
||||
class TsPlot(Analyzer):
|
||||
'''Generate a timestamp plots from a tracer log.
|
||||
|
||||
|
@ -123,18 +124,18 @@ class TsPlot(Analyzer):
|
|||
data = self.ev_data.get(ix)
|
||||
if not data:
|
||||
return
|
||||
l = self.ev_labels[ix]
|
||||
line = self.ev_labels[ix]
|
||||
ct = data['ct']
|
||||
x1 = data['first-ts']
|
||||
# TODO: scale 'y' according to max-y of buf or do a multiplot
|
||||
y = (1 + data['ypos']) * -10
|
||||
if ct == 1:
|
||||
pad_file.write('%f %f %f %f "%s"\n' % (x1, x1, 0.0, y, l))
|
||||
pad_file.write('%f %f %f %f "%s"\n' % (x1, x1, 0.0, y, line))
|
||||
else:
|
||||
x2 = data['last-ts']
|
||||
xd = (x2 - x1)
|
||||
xm = x1 + xd / 2
|
||||
pad_file.write('%f %f %f %f "%s (%d)"\n' % (x1, xm, xd, y, l, ct))
|
||||
pad_file.write('%f %f %f %f "%s (%d)"\n' % (x1, xm, xd, y, line, ct))
|
||||
|
||||
def _log_event(self, s):
|
||||
# build a [ts, event-name] data file
|
||||
|
@ -146,8 +147,8 @@ class TsPlot(Analyzer):
|
|||
x = int(s.values['ts']) / 1e9
|
||||
# some events fire often, labeling each would be unreadable
|
||||
# so we aggregate a series of events of the same type
|
||||
l = s.values['name']
|
||||
if l == self.ev_labels.get(ix):
|
||||
line = s.values['name']
|
||||
if line == self.ev_labels.get(ix):
|
||||
# count lines and track last ts
|
||||
data = self.ev_data[ix]
|
||||
data['ct'] += 1
|
||||
|
@ -155,17 +156,17 @@ class TsPlot(Analyzer):
|
|||
else:
|
||||
self._log_event_data(pad_file, ix)
|
||||
# start new data, assign a -y coord by event type
|
||||
if not ix in self.ev_ypos:
|
||||
if ix not in self.ev_ypos:
|
||||
ypos = {}
|
||||
self.ev_ypos[ix] = ypos
|
||||
else:
|
||||
ypos = self.ev_ypos[ix]
|
||||
if l in ypos:
|
||||
y = ypos[l]
|
||||
if line in ypos:
|
||||
y = ypos[line]
|
||||
else:
|
||||
y = len(ypos)
|
||||
ypos[l] = y
|
||||
self.ev_labels[ix] = l
|
||||
ypos[line] = y
|
||||
self.ev_labels[ix] = line
|
||||
self.ev_data[ix] = {
|
||||
'ct': 1,
|
||||
'first-ts': x,
|
||||
|
@ -187,7 +188,7 @@ class TsPlot(Analyzer):
|
|||
cts = int(s.values['ts']) / 1e9
|
||||
pts = int(s.values['buffer-pts']) / 1e9
|
||||
dur = int(s.values['buffer-duration']) / 1e9
|
||||
if not ix in self.buf_cts:
|
||||
if ix not in self.buf_cts:
|
||||
dcts = 0
|
||||
else:
|
||||
dcts = cts - self.buf_cts[ix]
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
try:
|
||||
from tracer.parser import Parser
|
||||
except:
|
||||
except BaseException:
|
||||
from parser import Parser
|
||||
|
||||
|
||||
class AnalysisRunner(object):
|
||||
"""
|
||||
Runs several Analyzers over a log.
|
||||
|
@ -26,9 +27,9 @@ class AnalysisRunner(object):
|
|||
analyzer.handle_tracer_entry(event)
|
||||
|
||||
def is_tracer_class(self, event):
|
||||
return (event[Parser.F_FILENAME] == 'gsttracerrecord.c' and
|
||||
event[Parser.F_CATEGORY] == 'GST_TRACER' and
|
||||
'.class' in event[Parser.F_MESSAGE])
|
||||
return (event[Parser.F_FILENAME] == 'gsttracerrecord.c'
|
||||
and event[Parser.F_CATEGORY] == 'GST_TRACER'
|
||||
and '.class' in event[Parser.F_MESSAGE])
|
||||
|
||||
def is_tracer_entry(self, event):
|
||||
return (not event[Parser.F_LINE] and not event[Parser.F_FILENAME])
|
||||
|
|
|
@ -30,14 +30,14 @@ class Structure(object):
|
|||
@staticmethod
|
||||
def _find_eos(s):
|
||||
# find next '"' without preceeding '\'
|
||||
l = 0
|
||||
i = 0
|
||||
# logger.debug("find_eos: '%s'", s)
|
||||
while 1: # faster than regexp for '[^\\]\"'
|
||||
while True: # faster than regexp for '[^\\]\"'
|
||||
p = s.index('"')
|
||||
l += p + 1
|
||||
i += p + 1
|
||||
if s[p - 1] != '\\':
|
||||
# logger.debug("... ok : '%s'", s[p:])
|
||||
return l
|
||||
return i
|
||||
s = s[(p + 1):]
|
||||
# logger.debug("... : '%s'", s)
|
||||
return -1
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
import sys
|
||||
import os
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
|
|
|
@ -49,9 +49,11 @@ import time
|
|||
|
||||
_bandwidth = 0
|
||||
|
||||
|
||||
class ThreadingSimpleServer(ThreadingMixIn, http.server.HTTPServer):
|
||||
pass
|
||||
|
||||
|
||||
class RangeHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
|
||||
|
||||
"""Simple HTTP request handler with GET and HEAD commands.
|
||||
|
@ -85,7 +87,7 @@ class RangeHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
|
|||
|
||||
try:
|
||||
self.wfile.write(f.read(chunk))
|
||||
except:
|
||||
except Exception:
|
||||
break
|
||||
total += chunk
|
||||
start_range += chunk
|
||||
|
@ -237,11 +239,11 @@ class RangeHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
|
|||
for word in words:
|
||||
drive, word = os.path.splitdrive(word)
|
||||
head, word = os.path.split(word)
|
||||
if word in (os.curdir, os.pardir): continue
|
||||
if word in (os.curdir, os.pardir):
|
||||
continue
|
||||
path = os.path.join(path, word)
|
||||
return path
|
||||
|
||||
|
||||
def guess_type(self, path):
|
||||
"""Guess the type of a file.
|
||||
|
||||
|
@ -283,6 +285,7 @@ class RangeHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
|
|||
def test(handler_class=RangeHTTPRequestHandler, server_class=http.server.HTTPServer):
|
||||
http.server.test(handler_class, server_class)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
httpd = ThreadingSimpleServer(("0.0.0.0", int(sys.argv[1])), RangeHTTPRequestHandler)
|
||||
httpd.serve_forever()
|
||||
|
|
|
@ -989,8 +989,9 @@ class GstValidateTest(Test):
|
|||
for key, value in report.items():
|
||||
if key == "type":
|
||||
continue
|
||||
res += '\n%s%s"%s": "%s",' % (" " * 12, "# " if key ==
|
||||
"details" else "", key, value.replace('\n', '\\n'))
|
||||
res += '\n%s%s"%s": "%s",' % (
|
||||
" " * 12, "# " if key == "details" else "",
|
||||
key, value.replace('\n', '\\n'))
|
||||
|
||||
res += "\n%s}," % (" " * 8)
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ import time
|
|||
from . import loggable
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
|
||||
logcat = "httpserver"
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ class TerminalController:
|
|||
# terminal has no capabilities.
|
||||
try:
|
||||
curses.setupterm()
|
||||
except:
|
||||
except BaseException:
|
||||
return
|
||||
|
||||
# Look up numeric capabilities.
|
||||
|
@ -258,15 +258,15 @@ class ProgressBar:
|
|||
self.cleared = 0
|
||||
n = int((self.width - 10) * percent)
|
||||
sys.stdout.write(
|
||||
self.term.BOL + self.term.UP + self.term.CLEAR_EOL +
|
||||
(self.bar % (100 * percent, '=' * n, '-' * (self.width - 10 - n))) +
|
||||
self.term.CLEAR_EOL + message.center(self.width))
|
||||
self.term.BOL + self.term.UP + self.term.CLEAR_EOL
|
||||
+ (self.bar % (100 * percent, '=' * n, '-' * (self.width - 10 - n)))
|
||||
+ self.term.CLEAR_EOL + message.center(self.width))
|
||||
|
||||
def clear(self):
|
||||
if not self.cleared:
|
||||
sys.stdout.write(self.term.BOL + self.term.CLEAR_EOL +
|
||||
self.term.UP + self.term.CLEAR_EOL +
|
||||
self.term.UP + self.term.CLEAR_EOL)
|
||||
sys.stdout.write(self.term.BOL + self.term.CLEAR_EOL
|
||||
+ self.term.UP + self.term.CLEAR_EOL
|
||||
+ self.term.UP + self.term.CLEAR_EOL)
|
||||
self.cleared = 1
|
||||
|
||||
|
||||
|
@ -648,7 +648,7 @@ def _preformatLevels(enableColorOutput):
|
|||
terminal_controller = TerminalController()
|
||||
for level in ERROR, WARN, FIXME, INFO, DEBUG, LOG:
|
||||
if enableColorOutput:
|
||||
if type(terminal_controller.BOLD) == bytes:
|
||||
if isinstance(terminal_controller.BOLD, bytes):
|
||||
formatter = ''.join(
|
||||
(terminal_controller.BOLD.decode(),
|
||||
getattr(terminal_controller, COLORS[level]).decode(),
|
||||
|
|
|
@ -21,6 +21,7 @@ import os
|
|||
import sys
|
||||
import xml.etree.cElementTree
|
||||
|
||||
|
||||
def extract_info(xmlfile):
|
||||
e = xml.etree.cElementTree.parse(xmlfile).getroot()
|
||||
r = {}
|
||||
|
@ -28,6 +29,7 @@ def extract_info(xmlfile):
|
|||
r[(i.get("classname"), i.get("name"))] = i
|
||||
return r
|
||||
|
||||
|
||||
if "__main__" == __name__:
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage : %s [<old run xml>] <new run xml>" % sys.argv[0])
|
||||
|
@ -58,9 +60,9 @@ if "__main__" == __name__:
|
|||
|
||||
if oldfile:
|
||||
# tests that weren't present in old run
|
||||
newtests = [x for x in newfile.keys() if not oldfile.has_key(x)]
|
||||
newtests = [x for x in newfile.keys() if x not in oldfile]
|
||||
# tests that are no longer present in new run
|
||||
gonetests = [x for x in oldfile.keys() if not newfile.has_key(x)]
|
||||
gonetests = [x for x in oldfile.keys() if x not in newfile]
|
||||
|
||||
# go over new tests
|
||||
for k, v in newfile.iteritems():
|
||||
|
@ -75,10 +77,10 @@ if "__main__" == __name__:
|
|||
rs = r.split('[')[1].split(']')[0].split(',')
|
||||
for la in rs:
|
||||
la = la.strip()
|
||||
if not reasons.has_key(la):
|
||||
if la not in reasons:
|
||||
reasons[la] = []
|
||||
reasons[la].append(k)
|
||||
if not failedfiles.has_key(fn):
|
||||
if fn not in failedfiles:
|
||||
failedfiles[fn] = []
|
||||
failedfiles[fn].append((tn, r))
|
||||
|
||||
|
@ -102,7 +104,6 @@ if "__main__" == __name__:
|
|||
elif a.get("message") != b.get("message"):
|
||||
failchange.append(k)
|
||||
|
||||
|
||||
if newfail:
|
||||
print("New failures", len(newfail))
|
||||
newfail.sort()
|
||||
|
@ -139,8 +140,7 @@ if "__main__" == __name__:
|
|||
print " %s : %s" % (i[0], i[1])
|
||||
print
|
||||
|
||||
nofailfiles = [fn for fn in allfiles if not failedfiles.has_key(fn)]
|
||||
nofailfiles.sort()
|
||||
nofailfiles = sorted([fn for fn in allfiles if fn not in failedfiles])
|
||||
if nofailfiles:
|
||||
print "Files without failures", len(nofailfiles)
|
||||
for f in nofailfiles:
|
||||
|
@ -151,4 +151,3 @@ if "__main__" == __name__:
|
|||
print "Failed File :", k
|
||||
for i in v:
|
||||
print " %s : %s" % (i[0], i[1])
|
||||
|
||||
|
|
Loading…
Reference in a new issue