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

Side by Side Diff: infra/bots/assets/skp/create.py

Issue 2175743004: Cherry-pick infra assets changes to chrome/m53 to prevent bots breaking (Closed) Base URL: https://skia.googlesource.com/skia.git@m53
Patch Set: Created 4 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
« no previous file with comments | « infra/bots/assets/skp/common.py ('k') | infra/bots/assets/skp/create_and_upload.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2016 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8
9 """Create the SKP asset."""
10
11
12 import argparse
13 import common
14 import os
15 import shutil
16 import subprocess
17 import utils
18
19
20 SKIA_TOOLS = os.path.join(common.INFRA_BOTS_DIR, os.pardir, os.pardir, 'tools')
21
22
23 def create_asset(chrome_src_path, browser_executable, target_dir,
24 upload_to_partner_bucket):
25 """Create the asset."""
26 browser_executable = os.path.realpath(browser_executable)
27 chrome_src_path = os.path.realpath(chrome_src_path)
28 target_dir = os.path.realpath(target_dir)
29
30 if not os.path.exists(target_dir):
31 os.makedirs(target_dir)
32
33 with utils.tmp_dir():
34 if os.environ.get('CHROME_HEADLESS'):
35 # Start Xvfb if running on a bot.
36 try:
37 subprocess.Popen(['sudo', 'Xvfb', ':0', '-screen', '0', '1280x1024x24'])
38 except Exception:
39 # It is ok if the above command fails, it just means that DISPLAY=:0
40 # is already up.
41 pass
42
43 webpages_playback_cmd = [
44 'python', os.path.join(SKIA_TOOLS, 'skp', 'webpages_playback.py'),
45 '--page_sets', 'all',
46 '--browser_executable', browser_executable,
47 '--non-interactive',
48 '--output_dir', os.getcwd(),
49 '--chrome_src_path', chrome_src_path,
50 ]
51 if upload_to_partner_bucket:
52 webpages_playback_cmd.append('--upload_to_partner_bucket')
53 try:
54 subprocess.check_call(webpages_playback_cmd)
55 finally:
56 # Clean up any leftover browser instances. This can happen if there are
57 # telemetry crashes, processes are not always cleaned up appropriately by
58 # the webpagereplay and telemetry frameworks.
59 procs = subprocess.check_output(['ps', 'ax'])
60 for line in procs.splitlines():
61 if browser_executable in line:
62 pid = line.strip().split(' ')[0]
63 if pid != str(os.getpid()) and not 'python' in line:
64 try:
65 subprocess.check_call(['kill', '-9', pid])
66 except subprocess.CalledProcessError as e:
67 print e
68 else:
69 print 'Refusing to kill self.'
70 src = os.path.join(os.getcwd(), 'playback', 'skps')
71 for f in os.listdir(src):
72 if f.endswith('.skp'):
73 shutil.copyfile(os.path.join(src, f), os.path.join(target_dir, f))
74
75
76 def main():
77 parser = argparse.ArgumentParser()
78 parser.add_argument('--target_dir', '-t', required=True)
79 parser.add_argument('--chrome_src_path', '-c', required=True)
80 parser.add_argument('--browser_executable', '-e', required=True)
81 parser.add_argument('--upload_to_partner_bucket', action='store_true')
82 args = parser.parse_args()
83 create_asset(args.chrome_src_path, args.browser_executable, args.target_dir,
84 args.upload_to_partner_bucket)
85
86
87 if __name__ == '__main__':
88 main()
OLDNEW
« no previous file with comments | « infra/bots/assets/skp/common.py ('k') | infra/bots/assets/skp/create_and_upload.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698