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

Unified Diff: scripts/slave/annotated_run.py

Issue 1884523002: Extract update_scripts out of annotated_run (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: presubmit 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/slave/unittests/annotated_run_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/annotated_run.py
diff --git a/scripts/slave/annotated_run.py b/scripts/slave/annotated_run.py
index cb5b9a4c34e4ff57ad70f665356f2b7090324532..4739782dacd6a31293d406394f8b7957cba9038e 100755
--- a/scripts/slave/annotated_run.py
+++ b/scripts/slave/annotated_run.py
@@ -27,6 +27,7 @@ from common import env
from common import master_cfg_utils
from slave import gce
from slave import infra_platform
+from slave import update_scripts
# Logging instance.
LOGGER = logging.getLogger('annotated_run')
@@ -765,75 +766,6 @@ def get_args(argv):
return parser.parse_args(argv)
-def update_scripts():
- if os.environ.get('RUN_SLAVE_UPDATED_SCRIPTS'):
- os.environ.pop('RUN_SLAVE_UPDATED_SCRIPTS')
- return False
-
- stream = annotator.StructuredAnnotationStream()
-
- with stream.step('update_scripts') as s:
- gclient_name = 'gclient'
- if sys.platform.startswith('win'):
- gclient_name += '.bat'
- gclient_path = os.path.join(env.Build, os.pardir, 'depot_tools',
- gclient_name)
- gclient_cmd = [gclient_path, 'sync', '--force', '--verbose', '--jobs=2',
- '--break_repo_locks']
- try:
- fd, output_json = tempfile.mkstemp()
- os.close(fd)
- gclient_cmd += ['--output-json', output_json]
- except Exception:
- # Super paranoia try block.
- output_json = None
- cmd_dict = {
- 'name': 'update_scripts',
- 'cmd': gclient_cmd,
- 'cwd': env.Build,
- }
- annotator.print_step(cmd_dict, os.environ, stream)
- rv, _ = _run_command(gclient_cmd, cwd=env.Build)
- if rv != 0:
- s.step_text('gclient sync failed!')
- s.step_exception()
- elif output_json:
- try:
- with open(output_json, 'r') as f:
- gclient_json = json.load(f)
- for line in json.dumps(
- gclient_json, sort_keys=True,
- indent=4, separators=(',', ': ')).splitlines():
- s.step_log_line('gclient_json', line)
- s.step_log_end('gclient_json')
-
- build_checkout = gclient_json['solutions'].get('build/')
- if build_checkout:
- s.step_text('%(scm)s - %(revision)s' % build_checkout)
- s.set_build_property('build_scm', json.dumps(build_checkout['scm']))
- s.set_build_property('build_revision',
- json.dumps(build_checkout['revision']))
- except Exception as e:
- s.step_text('Unable to process gclient JSON %s' % repr(e))
- s.step_exception()
- finally:
- try:
- os.remove(output_json)
- except Exception as e:
- LOGGER.warning("LEAKED: %s", output_json, exc_info=True)
- else:
- s.step_text('Unable to get SCM data')
- s.step_exception()
-
- os.environ['RUN_SLAVE_UPDATED_SCRIPTS'] = '1'
-
- # After running update scripts, set PYTHONIOENCODING=UTF-8 for the real
- # annotated_run.
- os.environ['PYTHONIOENCODING'] = 'UTF-8'
-
- return True
-
-
def clean_old_recipe_engine():
"""Clean stale pycs from the old location of recipe_engine.
@@ -977,7 +909,7 @@ def main(argv):
def shell_main(argv):
- if update_scripts():
+ if update_scripts.update_scripts():
# Re-execute with the updated annotated_run.py.
rv, _ = _run_command([sys.executable] + argv)
return rv
« no previous file with comments | « no previous file | scripts/slave/unittests/annotated_run_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698