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

Side by Side Diff: tools/perf/contrib/cluster_telemetry/screenshot.py

Issue 2957153002: Updating references from story.display_name to story.name (Closed)
Patch Set: Created 3 years, 5 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
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 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 4
5 import logging 5 import logging
6 import os 6 import os
7 import py_utils 7 import py_utils
8 import time 8 import time
9 9
10 from telemetry.page import legacy_page_test 10 from telemetry.page import legacy_page_test
11 from telemetry.util import image_util 11 from telemetry.util import image_util
12 12
13 class Screenshot(legacy_page_test.LegacyPageTest): 13 class Screenshot(legacy_page_test.LegacyPageTest):
14 """Takes a PNG screenshot of the page.""" 14 """Takes a PNG screenshot of the page."""
15 15
16 def __init__(self, png_outdir, wait_time=0): 16 def __init__(self, png_outdir, wait_time=0):
17 super(Screenshot, self).__init__() 17 super(Screenshot, self).__init__()
18 self._png_outdir = png_outdir 18 self._png_outdir = png_outdir
19 self._wait_time = wait_time 19 self._wait_time = wait_time
20 20
21 def ValidateAndMeasurePage(self, page, tab, results): 21 def ValidateAndMeasurePage(self, page, tab, results):
22 if not tab.screenshot_supported: 22 if not tab.screenshot_supported:
23 raise legacy_page_test.MeasurementFailure( 23 raise legacy_page_test.MeasurementFailure(
24 'Screenshotting not supported on this platform') 24 'Screenshotting not supported on this platform')
25 25
26 try: 26 try:
27 tab.WaitForDocumentReadyStateToBeComplete() 27 tab.WaitForDocumentReadyStateToBeComplete()
28 except py_utils.TimeoutException: 28 except py_utils.TimeoutException:
29 logging.warning("WaitForDocumentReadyStateToBeComplete() timeout, " + 29 logging.warning("WaitForDocumentReadyStateToBeComplete() timeout, " +
30 "page: %s", page.display_name) 30 "page: %s", page.name)
31 return 31 return
32 32
33 time.sleep(self._wait_time) 33 time.sleep(self._wait_time)
34 34
35 if not os.path.exists(self._png_outdir): 35 if not os.path.exists(self._png_outdir):
36 logging.info("Creating directory %s", self._png_outdir) 36 logging.info("Creating directory %s", self._png_outdir)
37 try: 37 try:
38 os.makedirs(self._png_outdir) 38 os.makedirs(self._png_outdir)
39 except OSError: 39 except OSError:
40 logging.warning("Directory %s could not be created", self._png_outdir) 40 logging.warning("Directory %s could not be created", self._png_outdir)
41 raise 41 raise
42 42
43 outpath = os.path.abspath( 43 outpath = os.path.abspath(
44 os.path.join(self._png_outdir, page.file_safe_name)) + '.png' 44 os.path.join(self._png_outdir, page.file_safe_name)) + '.png'
45 # Replace win32 path separator char '\' with '\\'. 45 # Replace win32 path separator char '\' with '\\'.
46 outpath = outpath.replace('\\', '\\\\') 46 outpath = outpath.replace('\\', '\\\\')
47 47
48 screenshot = tab.Screenshot() 48 screenshot = tab.Screenshot()
49 49
50 # TODO(lchoi): Add logging to image_util.py and/or augment error handling of 50 # TODO(lchoi): Add logging to image_util.py and/or augment error handling of
51 # image_util.WritePngFile 51 # image_util.WritePngFile
52 logging.info("Writing PNG file to %s. This may take awhile.", outpath) 52 logging.info("Writing PNG file to %s. This may take awhile.", outpath)
53 start = time.time() 53 start = time.time()
54 image_util.WritePngFile(screenshot, outpath) 54 image_util.WritePngFile(screenshot, outpath)
55 logging.info("PNG file written successfully. (Took %f seconds)", 55 logging.info("PNG file written successfully. (Took %f seconds)",
56 time.time()-start) 56 time.time()-start)
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/system_health_smoke_test.py ('k') | tools/perf/page_sets/key_idle_power_cases.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698