Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: tools/chrome_remote_control/chrome_remote_control/multi_page_benchmark.py

Issue 10984018: [chrome_remote_control] Add pylint to PRESUMMIT and fix lint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for landing Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import csv 4 import csv
5 import logging 5 import logging
6 import os 6 import os
7 import sys 7 import sys
8 import traceback
9 8
10 from chrome_remote_control import browser_finder 9 from chrome_remote_control import browser_finder
11 from chrome_remote_control import browser_options 10 from chrome_remote_control import browser_options
12 from chrome_remote_control import page_runner 11 from chrome_remote_control import page_runner
13 from chrome_remote_control import page_set 12 from chrome_remote_control import page_set
14 from chrome_remote_control import page_test 13 from chrome_remote_control import page_test
15 from chrome_remote_control import util
16 14
17 class MeasurementFailure(page_test.Failure): 15 class MeasurementFailure(page_test.Failure):
18 """Exception that can be thrown from MeasurePage to indicate an undesired but 16 """Exception that can be thrown from MeasurePage to indicate an undesired but
19 designed-for problem.""" 17 designed-for problem."""
20 pass 18 pass
21 19
22 class BenchmarkResults(page_test.PageTestResults): 20 class BenchmarkResults(page_test.PageTestResults):
23 def __init__(self): 21 def __init__(self):
24 super(BenchmarkResults, self).__init__() 22 super(BenchmarkResults, self).__init__()
25 self.page_results = [] 23 self.page_results = []
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 118
121 If args is not specified, sys.argv[1:] is used. 119 If args is not specified, sys.argv[1:] is used.
122 """ 120 """
123 options = browser_options.BrowserOptions() 121 options = browser_options.BrowserOptions()
124 parser = options.CreateParser('%prog [options] <page_set>') 122 parser = options.CreateParser('%prog [options] <page_set>')
125 benchmark.AddOptions(parser) 123 benchmark.AddOptions(parser)
126 _, args = parser.parse_args(args) 124 _, args = parser.parse_args(args)
127 125
128 if len(args) != 1: 126 if len(args) != 1:
129 parser.print_usage() 127 parser.print_usage()
130 import page_sets 128 import page_sets # pylint: disable=F0401
131 sys.stderr.write('Available pagesets:\n%s\n\n' % ',\n'.join( 129 sys.stderr.write('Available pagesets:\n%s\n\n' % ',\n'.join(
132 [os.path.relpath(f) for f in page_sets.GetAllPageSetFilenames()])) 130 [os.path.relpath(f) for f in page_sets.GetAllPageSetFilenames()]))
133 sys.exit(1) 131 sys.exit(1)
134 132
135 ps = page_set.PageSet.FromFile(args[0]) 133 ps = page_set.PageSet.FromFile(args[0])
136 134
137 benchmark.CustomizeBrowserOptions(options) 135 benchmark.CustomizeBrowserOptions(options)
138 possible_browser = browser_finder.FindBrowser(options) 136 possible_browser = browser_finder.FindBrowser(options)
139 if possible_browser == None: 137 if possible_browser == None:
140 sys.stderr.write( 138 sys.stderr.write(
141 'No browser found.\n' + 139 'No browser found.\n' +
142 'Use --browser=list to figure out which are available.\n') 140 'Use --browser=list to figure out which are available.\n')
143 sys.exit(1) 141 sys.exit(1)
144 142
145 results = CsvBenchmarkResults(csv.writer(sys.stdout)) 143 results = CsvBenchmarkResults(csv.writer(sys.stdout))
146 with page_runner.PageRunner(ps) as runner: 144 with page_runner.PageRunner(ps) as runner:
147 runner.Run(options, possible_browser, benchmark, results) 145 runner.Run(options, possible_browser, benchmark, results)
148 146
149 if len(results.page_failures): 147 if len(results.page_failures):
150 logging.warning('Failed pages: %s', '\n'.join( 148 logging.warning('Failed pages: %s', '\n'.join(
151 [failure['page'].url for failure in results.page_failures])) 149 [failure['page'].url for failure in results.page_failures]))
152 return max(255, len(results.page_failures)) 150 return max(255, len(results.page_failures))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698