Bug 1282398 - Fix all flake8 errors in testing/talos/talos. r=jmaher

This commit is contained in:
malayaleecoder 2016-06-29 11:05:18 +05:30
Родитель ce1e85f2a3
Коммит 69c18bd6cc
18 изменённых файлов: 68 добавлений и 68 удалений

Просмотреть файл

@ -133,7 +133,7 @@ def GetXRes(pids):
data = float(data)
XRes += data
except ValueError:
print "Invalid data, not a float"
print("Invalid data, not a float")
raise
else:
raise Exception("Could not find PID=%s in xrestop output" % pid)
@ -178,4 +178,4 @@ class LinuxCounterManager(CounterManager):
return [self.process.pid] + [child.pid
for child in self.process.children()]
except:
print "WARNING: problem updating child PID's"
print("WARNING: problem updating child PID's")

Просмотреть файл

@ -20,7 +20,7 @@ def GetProcessData(pid):
handle.wait()
data = handle.stdout.readlines()
except:
print "Unexpected error executing '%s': %s", (command, sys.exc_info())
print("Unexpected error executing '%s': %s", (command, sys.exc_info()))
raise
# First line is header output should look like:
@ -75,12 +75,12 @@ class MacCounterManager(CounterManager):
def getCounterValue(self, counterName):
"""Returns the last value of the counter 'counterName'"""
if counterName not in self.registeredCounters:
print ("Warning: attempting to collect counter %s and it is not"
" registered" % counterName)
print("Warning: attempting to collect counter %s and it is not"
" registered" % counterName)
return
try:
return self.registeredCounters[counterName][0](self.pid)
except Exception, e:
print ("Error in collecting counter: %s, pid: %s, exception: %s"
% (counterName, self.pid, e))
except Exception as e:
print("Error in collecting counter: %s, pid: %s, exception: %s"
% (counterName, self.pid, e))

Просмотреть файл

@ -22,17 +22,17 @@ class _StopAction(argparse.Action):
class _ListTests(_StopAction):
def __call__(self, parser, namespace, values, option_string=None):
from talos import test
print 'Available tests:'
print '================\n'
print('Available tests:')
print('================\n')
test_class_names = [
(test_class.name(), test_class.description())
for test_class in test.test_dict().itervalues()
]
test_class_names.sort()
for name, description in test_class_names:
print name
print '-'*len(name)
print description
print(name)
print('-'*len(name))
print(description)
print # Appends a single blank line to the end
parser.exit()
@ -40,12 +40,12 @@ class _ListTests(_StopAction):
class _ListSuite(_StopAction):
def __call__(self, parser, namespace, values, option_string=None):
from talos.config import suites_conf
print 'Available suites:'
print('Available suites:')
conf = suites_conf()
max_suite_name = max([len(s) for s in conf])
pattern = " %%-%ds (%%s)" % max_suite_name
for name in conf:
print pattern % (name, ':'.join(conf[name]['tests']))
print(pattern % (name, ':'.join(conf[name]['tests'])))
print
parser.exit()

Просмотреть файл

@ -467,6 +467,6 @@ def get_configs(argv=None):
if __name__ == '__main__':
cfgs = get_configs()
print cfgs[0]
print(cfgs[0])
print
print cfgs[1]
print(cfgs[1])

Просмотреть файл

@ -106,7 +106,7 @@ def dromaeo(series):
@define_filter
def dromaeo_chunks(series, size):
for i in xrange(0, len(series), size):
for i in range(0, len(series), size):
yield series[i:i+size]

Просмотреть файл

@ -87,7 +87,7 @@ def parse(logfilename, data):
stage = stage + 1
return True
except IOError as e:
print "%s: %s" % (e.filename, e.strerror)
print("%s: %s" % (e.filename, e.strerror))
return False
@ -108,21 +108,21 @@ def write_output(outfilename, data):
outfile.write("]\n")
return True
except IOError as e:
print "%s: %s" % (e.filename, e.strerror)
print("%s: %s" % (e.filename, e.strerror))
return False
def main(argv):
if len(argv) < 4:
print ("Usage: %s <main_thread_io_log_file> <output_file> <xre_path>"
% argv[0])
print("Usage: %s <main_thread_io_log_file> <output_file> <xre_path>"
% argv[0])
return 1
if not os.path.exists(argv[3]):
print "XRE Path \"%s\" does not exist" % argv[3]
print("XRE Path \"%s\" does not exist" % argv[3])
return 1
data = {}
if not parse(argv[1], data):
print "Log parsing failed"
print("Log parsing failed")
return 1
wl = whitelist.Whitelist(test_name='mainthreadio',
@ -130,7 +130,7 @@ def main(argv):
path_substitutions=PATH_SUBSTITUTIONS,
name_substitutions=NAME_SUBSTITUTIONS)
if not wl.load(WHITELIST_FILENAME):
print "Failed to load whitelist"
print("Failed to load whitelist")
return 1
wl.filter(data, TUPLE_FILENAME_INDEX)

Просмотреть файл

@ -197,7 +197,7 @@ class Output(object):
if 'spsProfile' not in self.results.extra_options:
LOG.info("PERFHERDER_DATA: %s" % json.dumps(results))
if results_scheme in ('file'):
json.dump(results, file(results_path, 'w'), indent=2,
json.dump(results, open(results_path, 'w'), indent=2,
sort_keys=True)
def post(self, results, server, path, scheme, tbpl_output):

Просмотреть файл

@ -266,7 +266,7 @@ class ProfileSymbolicator:
delta_time = profile_start_time - self.main_start_time
for i, thread in enumerate(profile_json["threads"]):
if isinstance(thread, basestring):
if isinstance(thread, str):
thread_json = json.loads(thread)
self.symbolicate_profile(thread_json)
profile_json["threads"][i] = json.dumps(thread_json)
@ -297,7 +297,7 @@ class ProfileSymbolicator:
def _find_addresses_v3(self, profile_json):
addresses = set()
for thread in profile_json["threads"]:
if isinstance(thread, basestring):
if isinstance(thread, str):
continue
for s in thread["stringTable"]:
if s[0:2] == "0x":
@ -306,7 +306,7 @@ class ProfileSymbolicator:
def _substitute_symbols_v3(self, profile_json, symbolication_table):
for thread in profile_json["threads"]:
if isinstance(thread, basestring):
if isinstance(thread, str):
continue
for i, s in enumerate(thread["stringTable"]):
thread["stringTable"][i] = symbolication_table.get(s, s)

Просмотреть файл

@ -25,11 +25,11 @@ class ModuleV3:
def getModuleV3(libName, breakpadId):
if not isinstance(libName, basestring) or not gLibNameRE.match(libName):
if not isinstance(libName, str) or not gLibNameRE.match(libName):
LogTrace("Bad library name: " + str(libName))
return None
if not isinstance(breakpadId, basestring):
if not isinstance(breakpadId, str):
LogTrace("Bad breakpad id: " + str(breakpadId))
return None
@ -72,7 +72,7 @@ class SymbolicationRequest:
return
if "forwarded" in rawRequests:
if not isinstance(rawRequests["forwarded"], (int, long)):
if not isinstance(rawRequests["forwarded"], (int, int)):
LogTrace("Invalid 'forwards' field: %s"
% rawRequests["forwarded"])
return

Просмотреть файл

@ -44,7 +44,7 @@ class TalosResults(object):
for url in urls:
_output.output(results, url, tbpl_output)
except utils.TalosError, e:
except utils.TalosError as e:
# print to results.out
try:
_output = output.GraphserverOutput(self)
@ -55,11 +55,11 @@ class TalosResults(object):
)
except:
pass
print '\nFAIL: %s' % str(e).replace('\n', '\nRETURN:')
print('\nFAIL: %s' % str(e).replace('\n', '\nRETURN:'))
raise e
if tbpl_output:
print "TinderboxPrint: TalosResult: %s" % json.dumps(tbpl_output)
print("TinderboxPrint: TalosResult: %s" % json.dumps(tbpl_output))
class TestResults(object):
@ -367,7 +367,7 @@ class BrowserLogResults(object):
try:
parts, last_token = utils.tokenize(self.results_raw,
start_token, end_token)
except AssertionError, e:
except AssertionError as e:
self.error(str(e))
if not parts:
return None, -1 # no match
@ -426,11 +426,11 @@ class BrowserLogResults(object):
filename = 'etl_output_thread_stats.csv'
if not os.path.exists(filename):
print ("Warning: we are looking for xperf results file %s, and"
" didn't find it" % filename)
print("Warning: we are looking for xperf results file %s, and"
" didn't find it" % filename)
return
contents = file(filename).read()
contents = open(filename).read()
lines = contents.splitlines()
reader = csv.reader(lines)
header = None
@ -458,11 +458,11 @@ class BrowserLogResults(object):
if (set(mainthread_counters).intersection(counter_results.keys())):
filename = 'etl_output.csv'
if not os.path.exists(filename):
print ("Warning: we are looking for xperf results file"
" %s, and didn't find it" % filename)
print("Warning: we are looking for xperf results file"
" %s, and didn't find it" % filename)
return
contents = file(filename).read()
contents = open(filename).read()
lines = contents.splitlines()
reader = csv.reader(lines)
header = None
@ -506,7 +506,7 @@ class BrowserLogResults(object):
os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
filename = os.path.join(SCRIPT_DIR, 'mainthread_io.json')
try:
contents = file(filename).read()
contents = open(filename).read()
counter_results.setdefault('mainthreadio', []).append(contents)
self.using_xperf = True
except:

Просмотреть файл

@ -150,7 +150,7 @@ def run_tests(config, browser_config):
browser_config['sourcestamp'] = version_info['application_changeset']
except KeyError:
if not browser_config['develop']:
print "unable to find changeset or repository: %s" % version_info
print("unable to find changeset or repository: %s" % version_info)
sys.exit()
else:
browser_config['repository'] = 'develop'
@ -207,14 +207,14 @@ def run_tests(config, browser_config):
LOG.error("Detected a regression for %s" % testname)
# by returning 1, we report an orange to buildbot
# http://docs.buildbot.net/latest/developer/results.html
LOG.test_end(testname, status='FAIL', message=unicode(exc),
LOG.test_end(testname, status='FAIL', message=str(exc),
stack=traceback.format_exc())
return 1
except Exception as exc:
# NOTE: if we get into this condition, talos has an internal
# problem and cannot continue
# this will prevent future tests from running
LOG.test_end(testname, status='ERROR', message=unicode(exc),
LOG.test_end(testname, status='ERROR', message=str(exc),
stack=traceback.format_exc())
# indicate a failure to buildbot, turn the job red
return 2
@ -228,8 +228,8 @@ def run_tests(config, browser_config):
if results_urls:
talos_results.output(results_urls)
if browser_config['develop'] or config['sps_profile']:
print ("Thanks for running Talos locally. Results are in %s"
% (results_urls['output_urls']))
print("Thanks for running Talos locally. Results are in %s"
% (results_urls['output_urls']))
# we will stop running tests on a failed test, or we will return 0 for
# green
@ -239,7 +239,7 @@ def run_tests(config, browser_config):
def main(args=sys.argv[1:]):
try:
config, browser_config = get_configs()
except ConfigurationError, exc:
except ConfigurationError as exc:
sys.exit("ERROR: %s" % exc)
sys.exit(run_tests(config, browser_config))

Просмотреть файл

@ -25,7 +25,7 @@ def generateTalosConfig(command_line, browser_config, test_config, pid=None):
('xperf_user_providers' in test_config) and
('xperf_stackwalk' in test_config)): # noqa
print "extending with xperf!"
print("extending with xperf!")
browser_config['xperf_providers'] = test_config['xperf_providers']
browser_config['xperf_user_providers'] = \
test_config['xperf_user_providers']

Просмотреть файл

@ -195,7 +195,7 @@ class TTest(object):
if line.strip() == "":
continue
print line
print(line)
mainthread_error_count += 1
mozfile.remove(rawlog)

Просмотреть файл

@ -38,7 +38,7 @@ class Whitelist:
self.listmap[whitelist_name.lower()] = temp[whitelist_name]
except IOError as e:
print "%s: %s" % (e.filename, e.strerror)
print("%s: %s" % (e.filename, e.strerror))
return False
return True
@ -136,8 +136,8 @@ class Whitelist:
def print_errors(self, error_strs):
for error_msg in error_strs:
print "TEST-UNEXPECTED-FAIL | %s | %s" % (self.test_name,
error_msg)
print("TEST-UNEXPECTED-FAIL | %s | %s" % (self.test_name,
error_msg))
# Note that we don't store dependent libs in listmap. This makes
# save_baseline cleaner. Since a baseline whitelist should not include
@ -154,5 +154,5 @@ class Whitelist:
{'ignore': True} for lib in libs}
return True
except IOError as e:
print "%s: %s" % (e.filename, e.strerror)
print("%s: %s" % (e.filename, e.strerror))
return False

Просмотреть файл

@ -79,7 +79,7 @@ def getIndex(eventType, colName):
def readFile(filename):
print "etlparser: in readfile: %s" % filename
print("etlparser: in readfile: %s" % filename)
data = csv.reader(open(filename, 'rb'), delimiter=',', quotechar='"',
skipinitialspace=True)
data = filterOutHeader(data)
@ -150,7 +150,7 @@ def etl2csv(xperf_path, etl_filename, debug=False):
'%s.kernel' % etl_filename,
etl_filename]
if debug:
print "executing '%s'" % subprocess.list2cmdline(xperf_cmd)
print("executing '%s'" % subprocess.list2cmdline(xperf_cmd))
subprocess.call(xperf_cmd)
csv_filename = '%s.csv' % etl_filename
@ -158,7 +158,7 @@ def etl2csv(xperf_path, etl_filename, debug=False):
'-i', etl_filename,
'-o', csv_filename]
if debug:
print "executing '%s'" % subprocess.list2cmdline(xperf_cmd)
print("executing '%s'" % subprocess.list2cmdline(xperf_cmd))
subprocess.call(xperf_cmd)
return csv_filename
@ -226,9 +226,9 @@ def loadWhitelist(filename):
if not filename:
return
if not os.path.exists(filename):
print "Warning: xperf whitelist %s was not found" % filename
print("Warning: xperf whitelist %s was not found" % filename)
return
lines = file(filename).readlines()
lines = open(filename).readlines()
# Expand paths
lines = [os.path.expandvars(elem.strip()) for elem in lines]
files = set()
@ -276,7 +276,7 @@ def etlparser(xperf_path, etl_filename, processID, approot=None,
io = {}
stage = 0
print "reading etl filename: %s" % etl_filename
print("reading etl filename: %s" % etl_filename)
csvname = etl2csv(xperf_path, etl_filename, debug=debug)
for row in readFile(csvname):
event = row[EVENTNAME_INDEX]
@ -304,7 +304,7 @@ def etlparser(xperf_path, etl_filename, processID, approot=None,
with open(fname, "w") as f:
f.write(output)
else:
print output
print(output)
whitelist = loadWhitelist(whitelist_file)
@ -447,7 +447,7 @@ def etlparser(xperf_path, etl_filename, processID, approot=None,
for error in errors:
# NOTE: the ' :' is intentional, without the space before the :,
# some parser will translate this
print "TEST-UNEXPECTED-FAIL : xperf: %s" % error
print("TEST-UNEXPECTED-FAIL : xperf: %s" % error)
# We detect if browser_failures.txt exists to exit and turn the job
# orange

Просмотреть файл

@ -14,7 +14,7 @@ import etlparser
def stop(xperf_path, debug=False):
xperf_cmd = [xperf_path, '-stop', '-stop', 'talos_ses']
if debug:
print "executing '%s'" % subprocess.list2cmdline(xperf_cmd)
print("executing '%s'" % subprocess.list2cmdline(xperf_cmd))
subprocess.call(xperf_cmd)
@ -67,7 +67,7 @@ def main(args=sys.argv[1:]):
stop_from_config(config_file=args.configFile,
debug=args.debug_level >= xtalos.DEBUG_INFO,
**args.__dict__)
except xtalos.XTalosError, e:
except xtalos.XTalosError as e:
parser.error(str(e))
if __name__ == "__main__":

Просмотреть файл

@ -26,7 +26,7 @@ def start(xperf_path, xperf_providers, xperf_stackwalk, xperf_user_providers,
'-f', '%s.user' % etl_filename
]
if debug:
print "executing '%s'" % subprocess.list2cmdline(xperf_cmd)
print("executing '%s'" % subprocess.list2cmdline(xperf_cmd))
subprocess.call(xperf_cmd)
@ -76,7 +76,7 @@ def main(args=sys.argv[1:]):
start_from_config(config_file=args.configFile,
debug=args.debug_level >= xtalos.DEBUG_INFO,
**args.__dict__)
except xtalos.XTalosError, e:
except xtalos.XTalosError as e:
parser.error(str(e))

Просмотреть файл

@ -120,7 +120,7 @@ class XtalosOptions(argparse.ArgumentParser):
# ensure xperf path exists
options.xperf_path = os.path.abspath(options.xperf_path)
if not os.path.exists(options.xperf_path):
print "ERROR: xperf_path '%s' does not exist" % options.xperf_path
print("ERROR: xperf_path '%s' does not exist" % options.xperf_path)
return None
return options