Commit 0f7acf8e authored by qyearsley's avatar qyearsley Committed by Commit bot

Update style according to advice from pylint.

BUG=

Review URL: https://codereview.chromium.org/681103002

Cr-Commit-Position: refs/heads/master@{#302139}
parent fcd9c476
......@@ -89,7 +89,7 @@ def _RunPyLint(input_api, output_api):
telemetry_path = os.path.join(
input_api.PresubmitLocalPath(), os.path.pardir, 'telemetry')
mock_path = os.path.join(
input_api.PresubmitLocalPath(),os.path.pardir, os.path.pardir,
input_api.PresubmitLocalPath(), os.path.pardir, os.path.pardir,
'third_party', 'pymock')
tests = input_api.canned_checks.GetPylint(
input_api, output_api, extra_paths_list=[telemetry_path, mock_path])
......
......@@ -152,7 +152,7 @@ def GetZipFileName(build_revision=None, target_arch='ia32', patch_sha=None):
if not build_revision:
return base_name
if patch_sha:
build_revision = '%s_%s' % (build_revision , patch_sha)
build_revision = '%s_%s' % (build_revision, patch_sha)
return '%s_%s.zip' % (base_name, build_revision)
......@@ -273,7 +273,7 @@ def WriteStringToFile(text, file_name):
with open(file_name, 'wb') as f:
f.write(text)
except IOError:
raise RuntimeError('Error writing to file [%s]' % file_name )
raise RuntimeError('Error writing to file [%s]' % file_name)
def ReadStringFromFile(file_name):
......@@ -282,7 +282,7 @@ def ReadStringFromFile(file_name):
with open(file_name) as f:
return f.read()
except IOError:
raise RuntimeError('Error reading file [%s]' % file_name )
raise RuntimeError('Error reading file [%s]' % file_name)
def ChangeBackslashToSlashInPatch(diff_text):
......@@ -317,7 +317,7 @@ def _ParseRevisionsFromDEPSFileManually(deps_file_contents):
# the DEPS file with the following format:
# 'depot_name': 'revision',
vars_body = re_results.group('vars_body')
rxp = re.compile("'(?P<depot_body>[\w_-]+)':[\s]+'(?P<rev_body>[\w@]+)'",
rxp = re.compile(r"'(?P<depot_body>[\w_-]+)':[\s]+'(?P<rev_body>[\w@]+)'",
re.MULTILINE)
re_results = rxp.findall(vars_body)
......@@ -503,18 +503,18 @@ def _TryParseResultValuesFromOutput(metric, text):
# The log will be parsed looking for format:
# <*>RESULT <graph_name>: <trace_name>= <value>
single_result_re = re.compile(
metric_re + '\s*(?P<VALUE>[-]?\d*(\.\d*)?)')
metric_re + r'\s*(?P<VALUE>[-]?\d*(\.\d*)?)')
# The log will be parsed looking for format:
# <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...]
multi_results_re = re.compile(
metric_re + '\s*\[\s*(?P<VALUES>[-]?[\d\., ]+)\s*\]')
metric_re + r'\s*\[\s*(?P<VALUES>[-]?[\d\., ]+)\s*\]')
# The log will be parsed looking for format:
# <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>}
mean_stddev_re = re.compile(
metric_re +
'\s*\{\s*(?P<MEAN>[-]?\d*(\.\d*)?),\s*(?P<STDDEV>\d+(\.\d*)?)\s*\}')
r'\s*\{\s*(?P<MEAN>[-]?\d*(\.\d*)?),\s*(?P<STDDEV>\d+(\.\d*)?)\s*\}')
text_lines = text.split('\n')
values_list = []
......@@ -703,7 +703,7 @@ def _PrepareBisectBranch(parent_branch, new_branch):
raise RunGitError('Failed to checkout branch: %s.' % output)
# Delete new branch if exists.
output, returncode = bisect_utils.RunGit(['branch', '--list' ])
output, returncode = bisect_utils.RunGit(['branch', '--list'])
if new_branch in output:
output, returncode = bisect_utils.RunGit(['branch', '-D', new_branch])
if returncode:
......@@ -870,7 +870,7 @@ class BisectPerformanceMetrics(object):
depot_data.get('platform') != os.name):
continue
if (depot_data.get('recurse') and depot in depot_data.get('from')):
if depot_data.get('recurse') and depot in depot_data.get('from'):
depot_data_src = depot_data.get('src') or depot_data.get('src_old')
src_dir = deps_data.get(depot_data_src)
if src_dir:
......@@ -1413,7 +1413,7 @@ class BisectPerformanceMetrics(object):
cwd=self.src_cwd)
if not commit_position:
return command_to_run
cmd_re = re.compile('--browser=(?P<browser_type>\S+)')
cmd_re = re.compile(r'--browser=(?P<browser_type>\S+)')
matches = cmd_re.search(command_to_run)
if bisect_utils.IsStringInt(commit_position) and matches:
cmd_browser = matches.group('browser_type')
......@@ -1502,8 +1502,8 @@ class BisectPerformanceMetrics(object):
current_args, cwd=self.src_cwd)
except OSError, e:
if e.errno == errno.ENOENT:
err_text = ('Something went wrong running the performance test. '
'Please review the command line:\n\n')
err_text = ('Something went wrong running the performance test. '
'Please review the command line:\n\n')
if 'src/' in ' '.join(args):
err_text += ('Check that you haven\'t accidentally specified a '
'path with src/ in the command.\n\n')
......@@ -1619,7 +1619,7 @@ class BisectPerformanceMetrics(object):
self.depot_registry.ChangeToDepotDir(depot)
if not ((num_resolved - 1) == num_needed):
if not (num_resolved - 1) == num_needed:
return None
return revisions_to_sync
......
......@@ -417,6 +417,7 @@ class DepotDirectoryRegistryTest(unittest.TestCase):
# The tests below test private functions (W0212).
# pylint: disable=W0212
class GitTryJobTestCases(unittest.TestCase):
"""Test case for bisect try job."""
def setUp(self):
bisect_utils_patcher = mock.patch('bisect_perf_regression.bisect_utils')
......@@ -434,10 +435,10 @@ class GitTryJobTestCases(unittest.TestCase):
def _AssertRunGitExceptions(self, git_cmds, func, *args):
"""Setup RunGit mock and tests RunGitException.
Args:
git_cmds: List of tuples with git command and expected output.
func: Callback function to be executed.
args: List of arguments to be passed to the function.
Args:
git_cmds: List of tuples with git command and expected output.
func: Callback function to be executed.
args: List of arguments to be passed to the function.
"""
self._SetupRunGitMock(git_cmds)
self.assertRaises(bisect_perf_regression.RunGitError,
......@@ -457,7 +458,8 @@ class GitTryJobTestCases(unittest.TestCase):
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
cmds = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (new_branch, 0)),
(['checkout', '-f', parent_branch], ('Checkout Failed', 1))]
(['checkout', '-f', parent_branch], ('Checkout Failed', 1)),
]
self._AssertRunGitExceptions(cmds,
bisect_perf_regression._PrepareBisectBranch,
parent_branch, new_branch)
......@@ -467,9 +469,9 @@ class GitTryJobTestCases(unittest.TestCase):
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
cmds = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (parent_branch, 0)),
(['branch', '--list' ], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('Failed to delete branch', 128))
]
(['branch', '--list'], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('Failed to delete branch', 128)),
]
self._AssertRunGitExceptions(cmds,
bisect_perf_regression._PrepareBisectBranch,
parent_branch, new_branch)
......@@ -479,13 +481,12 @@ class GitTryJobTestCases(unittest.TestCase):
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
cmds = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (parent_branch, 0)),
(['branch', '--list' ], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '--list'], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('None', 0)),
(['update-index', '--refresh', '-q'], (None, 0)),
(['diff-index', 'HEAD'], (None, 0)),
(['checkout', '-b', new_branch], ('Failed to create branch', 128))
]
(['checkout', '-b', new_branch], ('Failed to create branch', 128)),
]
self._AssertRunGitExceptions(cmds,
bisect_perf_regression._PrepareBisectBranch,
parent_branch, new_branch)
......@@ -495,17 +496,18 @@ class GitTryJobTestCases(unittest.TestCase):
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
cmds = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (parent_branch, 0)),
(['branch', '--list' ], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '--list'], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('None', 0)),
(['update-index', '--refresh', '-q'], (None, 0)),
(['diff-index', 'HEAD'], (None, 0)),
(['checkout', '-b', new_branch], ('None', 0)),
(['branch', '--set-upstream-to', parent_branch],
('Setuptream fails', 1))
]
('Setuptream fails', 1)),
]
self._AssertRunGitExceptions(cmds,
bisect_perf_regression._PrepareBisectBranch,
parent_branch, new_branch)
def testBuilderTryJobForException(self):
git_revision = 'ac4a9f31fe2610bd146857bbd55d7a260003a888'
bot_name = 'linux_perf_bisect_builder'
......@@ -516,7 +518,7 @@ class GitTryJobTestCases(unittest.TestCase):
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
try_cmd = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (parent_branch, 0)),
(['branch', '--list' ], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '--list'], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('None', 0)),
(['update-index', '--refresh', '-q'], (None, 0)),
(['diff-index', 'HEAD'], (None, 0)),
......@@ -529,8 +531,8 @@ class GitTryJobTestCases(unittest.TestCase):
'-n', bisect_job_name,
'--svn_repo=%s' % bisect_perf_regression.SVN_REPO_URL,
'--diff=%s' % patch_content
], (None, 1))
]
], (None, 1)),
]
self._AssertRunGitExceptions(try_cmd,
bisect_perf_regression._BuilderTryjob,
git_revision, bot_name, bisect_job_name, patch)
......@@ -545,7 +547,7 @@ class GitTryJobTestCases(unittest.TestCase):
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
try_cmd = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (parent_branch, 0)),
(['branch', '--list' ], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '--list'], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('None', 0)),
(['update-index', '--refresh', '-q'], (None, 0)),
(['diff-index', 'HEAD'], (None, 0)),
......@@ -558,8 +560,8 @@ class GitTryJobTestCases(unittest.TestCase):
'-n', bisect_job_name,
'--svn_repo=%s' % bisect_perf_regression.SVN_REPO_URL,
'--diff=%s' % patch_content
], (None, 0))
]
], (None, 0)),
]
self._SetupRunGitMock(try_cmd)
bisect_perf_regression._BuilderTryjob(
git_revision, bot_name, bisect_job_name, patch)
......@@ -567,3 +569,4 @@ class GitTryJobTestCases(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
......@@ -37,7 +37,7 @@ Date : %(cl_date)s"""
RESULTS_THANKYOU = """
| O O | Visit http://www.chromium.org/developers/core-principles for Chrome's
| X | policy on perf regressions. Contact chrome-perf-dashboard-team with any
| / \ | questions or suggestions about bisecting. THANK YOU."""
| / \\ | questions or suggestions about bisecting. THANK YOU."""
REPRO_STEPS_LOCAL = """
==== INSTRUCTIONS TO REPRODUCE ====
......
......@@ -258,7 +258,7 @@ def LoadExtraSrc(path_to_file):
def IsTelemetryCommand(command):
"""Attempts to discern whether or not a given command is running telemetry."""
return ('tools/perf/run_' in command or 'tools\\perf\\run_' in command)
return 'tools/perf/run_' in command or 'tools\\perf\\run_' in command
def _CreateAndChangeToSourceDirectory(working_directory):
......
......@@ -129,7 +129,7 @@ class BuildArchive(object):
"""
base_name = 'full-build-%s' % self._PlatformName()
if deps_patch_sha:
revision = '%s_%s' % (revision , deps_patch_sha)
revision = '%s_%s' % (revision, deps_patch_sha)
return '%s_%s.zip' % (base_name, revision)
def _PlatformName(self):
......@@ -264,7 +264,7 @@ def Unzip(filename, output_dir, verbose=True):
# Python zipfile module. If 7z is not installed, then this may fail if the
# zip file is larger than 512MB.
sevenzip_path = r'C:\Program Files\7-Zip\7z.exe'
if (bisect_utils.IsWindowsHost() and os.path.exists(sevenzip_path)):
if bisect_utils.IsWindowsHost() and os.path.exists(sevenzip_path):
unzip_command = [sevenzip_path, 'x', '-y']
_UnzipUsingCommand(unzip_command, filename, output_dir)
return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment