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

Side by Side Diff: scripts/slave/update_scripts.py

Issue 1869053002: kitchen_run: initial CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 4 years, 8 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
« scripts/slave/kitchen_run.py ('K') | « scripts/slave/kitchen_run.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import json
6 import logging
7 import os
8 import subprocess
9 import sys
10 import tempfile
11
12
13 # Install Infra build environment.
14 BUILD_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(
15 os.path.abspath(__file__))))
16 sys.path.insert(0, os.path.join(BUILD_ROOT, 'scripts'))
17
18 from common import annotator
19 from common import env
20
21
22 LOGGER = logging.getLogger('update_scripts')
23
24
25 def update_scripts():
26 if os.environ.get('RUN_SLAVE_UPDATED_SCRIPTS'):
27 os.environ.pop('RUN_SLAVE_UPDATED_SCRIPTS')
28 return False
29
30 stream = annotator.StructuredAnnotationStream()
31
32 with stream.step('update_scripts') as s:
33 gclient_name = 'gclient'
34 if sys.platform.startswith('win'):
35 gclient_name += '.bat'
36 gclient_path = os.path.join(env.Build, os.pardir, 'depot_tools',
37 gclient_name)
38 gclient_cmd = [gclient_path, 'sync', '--force', '--verbose', '--jobs=2',
39 '--break_repo_locks']
40 try:
41 fd, output_json = tempfile.mkstemp()
42 os.close(fd)
43 gclient_cmd += ['--output-json', output_json]
44 except Exception:
45 # Super paranoia try block.
46 output_json = None
47 cmd_dict = {
48 'name': 'update_scripts',
49 'cmd': gclient_cmd,
50 'cwd': env.Build,
51 }
52 annotator.print_step(cmd_dict, os.environ, stream)
53 LOGGER.debug('Executing command: %s', gclient_cmd)
54 proc = subprocess.Popen(
55 gclient_cmd, cwd=env.Build, stderr=subprocess.STDOUT)
56 stdout, _ = proc.communicate()
57 LOGGER.debug('Process [%s] returned [%d] with output:\n%s',
58 gclient_cmd, proc.returncode, stdout)
59 if proc.returncode != 0:
60 s.step_text('gclient sync failed!')
61 s.step_exception()
62 elif output_json:
63 try:
64 with open(output_json, 'r') as f:
65 gclient_json = json.load(f)
66 for line in json.dumps(
67 gclient_json, sort_keys=True,
68 indent=4, separators=(',', ': ')).splitlines():
69 s.step_log_line('gclient_json', line)
70 s.step_log_end('gclient_json')
71
72 build_checkout = gclient_json['solutions'].get('build/')
73 if build_checkout:
74 s.step_text('%(scm)s - %(revision)s' % build_checkout)
75 s.set_build_property('build_scm', json.dumps(build_checkout['scm']))
76 s.set_build_property('build_revision',
77 json.dumps(build_checkout['revision']))
78 except Exception as e:
79 s.step_text('Unable to process gclient JSON %s' % repr(e))
80 s.step_exception()
81 finally:
82 try:
83 os.remove(output_json)
84 except Exception as e:
85 LOGGER.warning("LEAKED: %s", output_json, exc_info=True)
86 else:
87 s.step_text('Unable to get SCM data')
88 s.step_exception()
89
90 os.environ['RUN_SLAVE_UPDATED_SCRIPTS'] = '1'
91
92 # After running update scripts, set PYTHONIOENCODING=UTF-8 for the real
93 # annotated_run.
94 os.environ['PYTHONIOENCODING'] = 'UTF-8'
95
96 return True
OLDNEW
« scripts/slave/kitchen_run.py ('K') | « scripts/slave/kitchen_run.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698