diff options
-rwxr-xr-x | binary_search_tool/binary_search_perforce.py | 2 | ||||
-rwxr-xr-x | binary_search_tool/test/binary_search_tool_test.py | 2 | ||||
-rwxr-xr-x | buildbot_test_toolchains.py | 40 | ||||
-rwxr-xr-x | chromiumos_image_diff.py | 2 | ||||
-rw-r--r-- | cros_utils/buildbot_utils.py | 1 | ||||
-rwxr-xr-x | cros_utils/device_setup_utils_unittest.py | 3 | ||||
-rw-r--r-- | cros_utils/logger.py | 1 | ||||
-rw-r--r-- | cros_utils/misc.py | 2 | ||||
-rw-r--r-- | cros_utils/tabulator.py | 6 | ||||
-rw-r--r-- | crosperf/experiment_factory.py | 4 | ||||
-rw-r--r-- | crosperf/experiment_file.py | 6 | ||||
-rw-r--r-- | crosperf/machine_manager.py | 6 | ||||
-rw-r--r-- | crosperf/results_report_templates.py | 6 | ||||
-rw-r--r-- | crosperf/suite_runner.py | 7 | ||||
-rwxr-xr-x | lock_machine.py | 6 |
15 files changed, 41 insertions, 53 deletions
diff --git a/binary_search_tool/binary_search_perforce.py b/binary_search_tool/binary_search_perforce.py index 5065f709..f2a3c8d5 100755 --- a/binary_search_tool/binary_search_perforce.py +++ b/binary_search_tool/binary_search_perforce.py @@ -369,7 +369,7 @@ class P4BinarySearcher(VCSBinarySearcher): self.ce.RunCommand(command) command = 'cd %s' % self.checkout_dir command += '; g4 changes -c %s' % self.client_name - _, out, _ = self.ce.RunCommandWOUTPUOT(command) + _, out, _ = self.ce.RunCommandWOutput(command) changes = re.findall(r'Change (\d+)', out) if changes: command = 'cd %s' % self.checkout_dir diff --git a/binary_search_tool/test/binary_search_tool_test.py b/binary_search_tool/test/binary_search_tool_test.py index ca9313b5..6f5b514e 100755 --- a/binary_search_tool/test/binary_search_tool_test.py +++ b/binary_search_tool/test/binary_search_tool_test.py @@ -202,7 +202,7 @@ class BisectingUtilsTest(unittest.TestCase): f.write('test123') bss = binary_search_state.MockBinarySearchState() - with self.assertRaises(binary_search_state.Error): + with self.assertRaises(OSError): bss.SaveState() with open(state_file, 'r', encoding='utf-8') as f: diff --git a/buildbot_test_toolchains.py b/buildbot_test_toolchains.py index 5f7c21d3..1609da49 100755 --- a/buildbot_test_toolchains.py +++ b/buildbot_test_toolchains.py @@ -204,23 +204,23 @@ class ToolchainComparator(object): # Now add vanilla to test file. official_image = """ - vanilla_image { - chromeos_root: %s - build: %s - compiler: llvm - } - """ % (self._chromeos_root, vanilla_image) + vanilla_image { + chromeos_root: %s + build: %s + compiler: llvm + } + """ % (self._chromeos_root, vanilla_image) f.write(official_image) # Now add non-AFDO image to test file. if nonafdo_image: official_nonafdo_image = """ - nonafdo_image { - chromeos_root: %s - build: %s - compiler: llvm - } - """ % (self._chromeos_root, nonafdo_image) + nonafdo_image { + chromeos_root: %s + build: %s + compiler: llvm + } + """ % (self._chromeos_root, nonafdo_image) f.write(official_nonafdo_image) label_string = '%s_trybot_image' % compiler_string @@ -228,14 +228,14 @@ class ToolchainComparator(object): # Reuse autotest files from vanilla image for trybot images autotest_files = os.path.join('/tmp', vanilla_image, 'autotest_files') experiment_image = """ - %s { - chromeos_root: %s - build: %s - autotest_path: %s - compiler: %s - } - """ % (label_string, self._chromeos_root, trybot_image, - autotest_files, compiler_string) + %s { + chromeos_root: %s + build: %s + autotest_path: %s + compiler: %s + } + """ % (label_string, self._chromeos_root, trybot_image, autotest_files, + compiler_string) f.write(experiment_image) crosperf = os.path.join(TOOLCHAIN_DIR, 'crosperf', 'crosperf') diff --git a/chromiumos_image_diff.py b/chromiumos_image_diff.py index 66a54ccc..3d54100d 100755 --- a/chromiumos_image_diff.py +++ b/chromiumos_image_diff.py @@ -318,7 +318,7 @@ def Main(argv): for i, image_path in enumerate([options.image1, options.image2], start=1): image_path = os.path.realpath(image_path) if not os.path.isfile(image_path): - logger.getLogger().LogError('"{0}" is not a file.'.format(image_path)) + logger.GetLogger().LogError('"{0}" is not a file.'.format(image_path)) return 1 chromeos_root = None diff --git a/cros_utils/buildbot_utils.py b/cros_utils/buildbot_utils.py index a06abd26..428433db 100644 --- a/cros_utils/buildbot_utils.py +++ b/cros_utils/buildbot_utils.py @@ -27,7 +27,6 @@ TIME_OUT = 43200 # Decide the build is dead or will never finish class BuildbotTimeout(Exception): """Exception to throw when a buildbot operation timesout.""" - pass def RunCommandInPath(path, cmd): diff --git a/cros_utils/device_setup_utils_unittest.py b/cros_utils/device_setup_utils_unittest.py index 63f9bf66..12a70811 100755 --- a/cros_utils/device_setup_utils_unittest.py +++ b/cros_utils/device_setup_utils_unittest.py @@ -14,10 +14,9 @@ import time import unittest from unittest import mock -from device_setup_utils import DutWrapper - from cros_utils import command_executer from cros_utils import logger +from cros_utils.device_setup_utils import DutWrapper BIG_LITTLE_CPUINFO = """processor : 0 model name : ARMv8 Processor rev 4 (v8l) diff --git a/cros_utils/logger.py b/cros_utils/logger.py index 4cc4618e..e304fe12 100644 --- a/cros_utils/logger.py +++ b/cros_utils/logger.py @@ -207,7 +207,6 @@ class MockLogger(object): def __init__(self, *_args, **_kwargs): self.stdout = sys.stdout self.stderr = sys.stderr - return None def _AddSuffix(self, basename, suffix): return '%s%s' % (basename, suffix) diff --git a/cros_utils/misc.py b/cros_utils/misc.py index 246767f0..b4beb60c 100644 --- a/cros_utils/misc.py +++ b/cros_utils/misc.py @@ -462,7 +462,7 @@ def ApplyGerritPatches(chromeos_root, gerrit_patch_string, sys.path.append(os.path.join(chromeos_root, 'chromite')) # Imports below are ok after modifying path to add chromite. # Pylint cannot detect that and complains. - # pylint: disable=import-error + # pylint: disable=import-error, import-outside-toplevel from lib import git from lib import gerrit manifest = git.ManifestCheckout(chromeos_root) diff --git a/cros_utils/tabulator.py b/cros_utils/tabulator.py index 300c2d79..5029ceee 100644 --- a/cros_utils/tabulator.py +++ b/cros_utils/tabulator.py @@ -318,7 +318,7 @@ class SamplesTableGenerator(TableGenerator): v.append(None) run_fail += 1 one_tuple = ((run_pass, run_fail), v) - if iterations != 0 and iterations != run_pass + run_fail: + if iterations not in (0, run_pass + run_fail): raise ValueError('Iterations of each benchmark run ' \ 'are not the same') iterations = run_pass + run_fail @@ -358,7 +358,7 @@ class SamplesTableGenerator(TableGenerator): # Accumulate each run result to composite benchmark run # If any run fails, then we set this run for composite benchmark # to None so that we know it fails. - if bench_runs[index] and row[label_index][index] != None: + if bench_runs[index] and row[label_index][index] is not None: row[label_index][index] += bench_runs[index] else: row[label_index][index] = None @@ -557,12 +557,10 @@ class AmeanResult(StringMeanResult): class RawResult(Result): """Raw result.""" - pass class IterationResult(Result): """Iteration result.""" - pass class MinResult(Result): diff --git a/crosperf/experiment_factory.py b/crosperf/experiment_factory.py index 4527db5f..3b1ed614 100644 --- a/crosperf/experiment_factory.py +++ b/crosperf/experiment_factory.py @@ -229,8 +229,8 @@ class ExperimentFactory(object): iterations = benchmark_settings.GetField('iterations') if cwp_dso: - if cwp_dso_iterations != 0 and iterations != cwp_dso_iterations: - raise RuntimeError('Iterations of each benchmark run are not the ' \ + if cwp_dso_iterations not in (0, iterations): + raise RuntimeError('Iterations of each benchmark run are not the ' 'same') cwp_dso_iterations = iterations diff --git a/crosperf/experiment_file.py b/crosperf/experiment_file.py index 1d89edad..d2831bda 100644 --- a/crosperf/experiment_file.py +++ b/crosperf/experiment_file.py @@ -95,7 +95,8 @@ class ExperimentFile(object): if not line: continue - elif ExperimentFile._FIELD_VALUE_RE.match(line): + + if ExperimentFile._FIELD_VALUE_RE.match(line): field = self._ParseField(reader) settings.SetField(field[0], field[1], field[2]) elif ExperimentFile._CLOSE_SETTINGS_RE.match(line): @@ -113,7 +114,8 @@ class ExperimentFile(object): if not line: continue - elif ExperimentFile._OPEN_SETTINGS_RE.match(line): + + if ExperimentFile._OPEN_SETTINGS_RE.match(line): new_settings, settings_type = self._ParseSettings(reader) # We will allow benchmarks with duplicated settings name for now. # Further decision will be made when parsing benchmark details in diff --git a/crosperf/machine_manager.py b/crosperf/machine_manager.py index 7211662c..0b38eef2 100644 --- a/crosperf/machine_manager.py +++ b/crosperf/machine_manager.py @@ -28,12 +28,10 @@ CHECKSUM_FILE = '/usr/local/osimage_checksum_file' class BadChecksum(Exception): """Raised if all machines for a label don't have the same checksum.""" - pass class BadChecksumString(Exception): """Raised if all machines for a label don't have the same checksum string.""" - pass class MissingLocksDirectory(Exception): @@ -298,8 +296,8 @@ class MachineManager(object): retval = image_chromeos.DoImage(image_chromeos_args) if retval: raise RuntimeError("Could not image machine: '%s'." % machine.name) - else: - self.num_reimages += 1 + + self.num_reimages += 1 machine.checksum = checksum machine.image = label.chromeos_image machine.label = label diff --git a/crosperf/results_report_templates.py b/crosperf/results_report_templates.py index 3c5258c9..ea411e21 100644 --- a/crosperf/results_report_templates.py +++ b/crosperf/results_report_templates.py @@ -6,7 +6,7 @@ """Text templates used by various parts of results_report.""" from __future__ import print_function -import cgi +import html from string import Template _TabMenuTemplate = Template(""" @@ -19,7 +19,7 @@ _TabMenuTemplate = Template(""" def _GetTabMenuHTML(table_name): # N.B. cgi.escape does some very basic HTML escaping. Nothing more. - escaped = cgi.escape(table_name, quote=True) + escaped = html.escape(table_name) return _TabMenuTemplate.substitute(table_name=escaped) @@ -35,7 +35,7 @@ _ExperimentFileHTML = """ def _GetExperimentFileHTML(experiment_file_text): if not experiment_file_text: return '' - return _ExperimentFileHTML % (cgi.escape(experiment_file_text),) + return _ExperimentFileHTML % (html.escape(experiment_file_text, quote=False),) _ResultsSectionHTML = Template(""" diff --git a/crosperf/suite_runner.py b/crosperf/suite_runner.py index 79ace20d..62a85cc6 100644 --- a/crosperf/suite_runner.py +++ b/crosperf/suite_runner.py @@ -166,11 +166,10 @@ class SuiteRunner(object): # process namespace and we can kill process created easily by their # process group. chrome_root_options = ('--no-ns-pid ' - '--chrome_root={} --chrome_root_mount={} ' + '--chrome_root={0} --chrome_root_mount={1} ' 'FEATURES="-usersandbox" ' - 'CHROME_ROOT={}'.format(label.chrome_src, - CHROME_MOUNT_DIR, - CHROME_MOUNT_DIR)) + 'CHROME_ROOT={1}'.format(label.chrome_src, + CHROME_MOUNT_DIR)) if self.log_level != 'verbose': self.logger.LogOutput('Running test.') diff --git a/lock_machine.py b/lock_machine.py index 06c0e80c..2948381d 100755 --- a/lock_machine.py +++ b/lock_machine.py @@ -518,12 +518,6 @@ def Main(argv): lock_manager.CheckMachineLocks(machine_states, cmd) lock_manager.UpdateMachines(False) - elif cmd == 'add': - lock_manager.AddMachinesToLocalServer() - - elif cmd == 'remove': - lock_manager.RemoveMachinesFromLocalServer() - return 0 |