diff options
author | Zhizhou Yang <zhizhouy@google.com> | 2020-02-13 15:51:36 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-14 08:52:40 +0000 |
commit | cbc6a9d99bdd4c7180f5e309de09039d6d9c9dbd (patch) | |
tree | 2e65a7782d8dd967641247c04cb8b45c010c9e57 /crosperf | |
parent | ac96cb3e307c7edb96b05994b9deade0978c1e78 (diff) | |
download | toolchain-utils-cbc6a9d99bdd4c7180f5e309de09039d6d9c9dbd.tar.gz |
toolchain-utils: fix cros lint and some random errors
We have enabled --py3 for cros lint and thus reveals some new linting
errors in migrated scripts. This patch fixes them and some other random
errors.
BUG=chromium:1011676
TEST=Passed unittests.
Change-Id: If129e01c21845e1b944a2b64e50e9fed7138c845
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2055972
Tested-by: Zhizhou Yang <zhizhouy@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Commit-Queue: Zhizhou Yang <zhizhouy@google.com>
Auto-Submit: Zhizhou Yang <zhizhouy@google.com>
Diffstat (limited to 'crosperf')
-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 |
5 files changed, 14 insertions, 15 deletions
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.') |