OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 | 6 |
7 """Run the webpages_playback automation script.""" | 7 """Run the webpages_playback automation script.""" |
8 | 8 |
9 | 9 |
10 import os | 10 import os |
(...skipping 18 matching lines...) Expand all Loading... | |
29 # Find the first SKP version which has no uploaded SKPs. | 29 # Find the first SKP version which has no uploaded SKPs. |
30 new_version = current_skp_version + 1 | 30 new_version = current_skp_version + 1 |
31 while True: | 31 while True: |
32 gs_path = 'playback_%d/skps' % new_version | 32 gs_path = 'playback_%d/skps' % new_version |
33 if not gs_utils.GSUtils().does_storage_object_exist('chromium-skia-gm', | 33 if not gs_utils.GSUtils().does_storage_object_exist('chromium-skia-gm', |
34 gs_path): | 34 gs_path): |
35 return new_version | 35 return new_version |
36 new_version += 1 | 36 new_version += 1 |
37 | 37 |
38 | 38 |
39 def main(chrome_src_path, browser_executable): | 39 def main(chrome_src_path, browser_executable, dry_run): |
40 browser_executable = os.path.realpath(browser_executable) | 40 browser_executable = os.path.realpath(browser_executable) |
41 dry_run = (dry_run == 'True') | |
41 skp_version = _get_skp_version() | 42 skp_version = _get_skp_version() |
42 print 'SKP_VERSION=%d' % skp_version | 43 print 'SKP_VERSION=%d' % skp_version |
43 | 44 |
44 if os.environ.get('CHROME_HEADLESS'): | 45 if os.environ.get('CHROME_HEADLESS'): |
45 # Start Xvfb if running on a bot. | 46 # Start Xvfb if running on a bot. |
46 try: | 47 try: |
47 shell_utils.run('sudo Xvfb :0 -screen 0 1280x1024x24 &', shell=True) | 48 shell_utils.run('sudo Xvfb :0 -screen 0 1280x1024x24 &', shell=True) |
48 except Exception: | 49 except Exception: |
49 # It is ok if the above command fails, it just means that DISPLAY=:0 | 50 # It is ok if the above command fails, it just means that DISPLAY=:0 |
50 # is already up. | 51 # is already up. |
51 pass | 52 pass |
52 | 53 |
53 upload_dir = 'playback_%d' % skp_version | 54 upload_dir = 'playback_%d' % skp_version |
54 webpages_playback_cmd = [ | 55 webpages_playback_cmd = [ |
55 'python', os.path.join(os.path.dirname(os.path.realpath(__file__)), | 56 'python', os.path.join(os.path.dirname(os.path.realpath(__file__)), |
56 'webpages_playback.py'), | 57 'webpages_playback.py'), |
57 '--page_sets', 'all', | 58 '--page_sets', 'all', |
58 '--browser_executable', browser_executable, | 59 '--browser_executable', browser_executable, |
59 '--non-interactive', | 60 '--non-interactive', |
60 '--upload', | 61 '--upload', |
61 '--upload_to_partner_bucket', | |
62 '--alternate_upload_dir', upload_dir, | 62 '--alternate_upload_dir', upload_dir, |
63 '--chrome_src_path', chrome_src_path, | 63 '--chrome_src_path', chrome_src_path, |
64 ] | 64 ] |
65 if not dry_run: | |
66 webpages_playback_cmd.append('--upload_to_partner_bucket') | |
65 | 67 |
66 try: | 68 try: |
67 shell_utils.run(webpages_playback_cmd) | 69 shell_utils.run(webpages_playback_cmd) |
68 finally: | 70 finally: |
69 # Clean up any leftover browser instances. This can happen if there are | 71 # Clean up any leftover browser instances. This can happen if there are |
70 # telemetry crashes, processes are not always cleaned up appropriately by | 72 # telemetry crashes, processes are not always cleaned up appropriately by |
71 # the webpagereplay and telemetry frameworks. | 73 # the webpagereplay and telemetry frameworks. |
72 procs = subprocess.check_output(['ps', 'ax']) | 74 procs = subprocess.check_output(['ps', 'ax']) |
73 for line in procs.splitlines(): | 75 for line in procs.splitlines(): |
74 if browser_executable in line: | 76 if browser_executable in line: |
75 pid = line.strip().split(' ')[0] | 77 pid = line.strip().split(' ')[0] |
76 if pid != str(os.getpid()) and not 'python' in line: | 78 if pid != str(os.getpid()) and not 'python' in line: |
77 try: | 79 try: |
78 shell_utils.run(['kill', '-9', pid]) | 80 shell_utils.run(['kill', '-9', pid]) |
79 except shell_utils.CommandFailedException as e: | 81 except shell_utils.CommandFailedException as e: |
80 print e | 82 print e |
81 else: | 83 else: |
82 print 'Refusing to kill self.' | 84 print 'Refusing to kill self.' |
83 | 85 |
84 print 'writing %s: %s' % (SKP_VERSION_FILE, skp_version) | 86 print 'writing %s: %s' % (SKP_VERSION_FILE, skp_version) |
85 with open(SKP_VERSION_FILE, 'w') as f: | 87 with open(SKP_VERSION_FILE, 'w') as f: |
86 f.write(str(skp_version)) | 88 f.write(str(skp_version)) |
87 | 89 |
88 | 90 |
89 if '__main__' == __name__: | 91 if '__main__' == __name__: |
90 if len(sys.argv) != 3: | 92 if len(sys.argv) != 4: |
91 print >> sys.stderr, 'USAGE: %s <chrome src path> <browser executable>' | 93 print >> sys.stderr, ('USAGE: %s <chrome src path> <browser executable> ' |
94 '<dry run>') | |
borenet
2016/02/03 13:06:34
Why not --upload_to_partner_bucket?
rmistry
2016/02/03 13:09:28
I think it will be useful to have information whet
borenet
2016/02/03 13:12:02
Okay, I thought dry run meant that we didn't uploa
borenet
2016/02/03 13:23:34
Ah, got it, thanks.
| |
92 sys.exit(1) | 95 sys.exit(1) |
93 main(*sys.argv[1:]) | 96 main(*sys.argv[1:]) |
OLD | NEW |