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

Side by Side Diff: slave/run_slave.py

Issue 18457003: Use corrected env for first sync too. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """ Initialize the environment variables and start the buildbot slave. 6 """ Initialize the environment variables and start the buildbot slave.
7 """ 7 """
8 8
9 import os 9 import os
10 import re 10 import re
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 tw_ver = getattr(master, 'twisted_version', tw_ver) 274 tw_ver = getattr(master, 'twisted_version', tw_ver)
275 print 'Using %s and %s' % (bb_ver, tw_ver) 275 print 'Using %s and %s' % (bb_ver, tw_ver)
276 return (bb_ver, tw_ver) 276 return (bb_ver, tw_ver)
277 277
278 278
279 def error(msg): 279 def error(msg):
280 print >> sys.stderr, msg 280 print >> sys.stderr, msg
281 sys.exit(1) 281 sys.exit(1)
282 282
283 283
284 def UseBotoPath():
285 """Mutate the environment to reference the prefered gs credentials."""
286 # Get the path to the boto file containing the password.
287 boto_file = os.path.join(BUILD_DIR, 'site_config', '.boto')
288 # If the boto file exists, make sure gsutil uses this boto file.
289 if os.path.exists(boto_file):
290 os.environ['AWS_CREDENTIAL_FILE'] = boto_file
291 os.environ['BOTO_CONFIG'] = boto_file
292
293
284 def main(): 294 def main():
285 # Use adhoc argument parsing because of twisted's twisted argument parsing. 295 # Use adhoc argument parsing because of twisted's twisted argument parsing.
286 # Change the current directory to the directory of the script. 296 # Change the current directory to the directory of the script.
287 os.chdir(SCRIPT_DIR) 297 os.chdir(SCRIPT_DIR)
288 depot_tools = os.path.join(ROOT_DIR, 'depot_tools') 298 depot_tools = os.path.join(ROOT_DIR, 'depot_tools')
289 if not os.path.isdir(depot_tools): 299 if not os.path.isdir(depot_tools):
290 error('You must put a copy of depot_tools in %s' % depot_tools) 300 error('You must put a copy of depot_tools in %s' % depot_tools)
291 bot_password_file = os.path.normpath( 301 bot_password_file = os.path.normpath(
292 os.path.join(BUILD_DIR, 'site_config', '.bot_password')) 302 os.path.join(BUILD_DIR, 'site_config', '.bot_password'))
293 if not os.path.isfile(bot_password_file): 303 if not os.path.isfile(bot_password_file):
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 depot_tools, 442 depot_tools,
433 # Reuse the python executable used to start this script. 443 # Reuse the python executable used to start this script.
434 os.path.dirname(sys.executable), 444 os.path.dirname(sys.executable),
435 '/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin' 445 '/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin'
436 ] 446 ]
437 os.environ['PATH'] = os.pathsep.join(slave_path) 447 os.environ['PATH'] = os.pathsep.join(slave_path)
438 448
439 else: 449 else:
440 error('Platform %s is not implemented yet' % sys.platform) 450 error('Platform %s is not implemented yet' % sys.platform)
441 451
442 # Get the path to the boto file containing the password. 452 # This may be redundant, unless this is imported and main is called.
443 boto_file = os.path.join(BUILD_DIR, 'site_config', '.boto') 453 UseBotoPath()
444 # If the boto file exists, make sure gsutil uses this boto file.
445 if os.path.exists(boto_file):
446 os.environ['AWS_CREDENTIAL_FILE'] = boto_file
447 os.environ['BOTO_CONFIG'] = boto_file
448 454
449 # This envrionment is defined only when testing the slave on a dev machine. 455 # This envrionment is defined only when testing the slave on a dev machine.
450 is_testing = 'TESTING_MASTER' in os.environ 456 is_testing = 'TESTING_MASTER' in os.environ
451 if not is_testing: 457 if not is_testing:
452 # Don't overwrite the ~/.subversion/config file when TESTING_MASTER is set. 458 # Don't overwrite the ~/.subversion/config file when TESTING_MASTER is set.
453 FixSubversionConfig() 459 FixSubversionConfig()
454 HotPatchSlaveBuilder(is_testing) 460 HotPatchSlaveBuilder(is_testing)
455 461
456 import twisted.scripts.twistd as twistd 462 import twisted.scripts.twistd as twistd
457 twistd.run() 463 twistd.run()
458 if needs_reboot: 464 if needs_reboot:
459 # Send the appropriate system shutdown command. 465 # Send the appropriate system shutdown command.
460 Reboot() 466 Reboot()
461 # This line should not be reached. 467 # This line should not be reached.
462 468
463 469
464 def GetGClientPath(): 470 def GetGClientPath():
465 """Returns path to local gclient executable.""" 471 """Returns path to local gclient executable."""
466 gclient_path = os.path.join(ROOT_DIR, 'depot_tools', 'gclient') 472 gclient_path = os.path.join(ROOT_DIR, 'depot_tools', 'gclient')
467 if sys.platform.startswith('win'): 473 if sys.platform.startswith('win'):
468 return gclient_path + '.bat' 474 return gclient_path + '.bat'
469 return gclient_path 475 return gclient_path
470 476
471 477
472 if '__main__' == __name__: 478 if '__main__' == __name__:
473 skip_sync_arg = '--no-gclient-sync' 479 skip_sync_arg = '--no-gclient-sync'
474 if skip_sync_arg not in sys.argv: 480 if skip_sync_arg not in sys.argv:
481 UseBotoPath()
Isaac (away) 2013/07/04 20:56:15 Move this one line up and I think you can skip the
475 if subprocess.call([GetGClientPath(), 'sync', '--force']) != 0: 482 if subprocess.call([GetGClientPath(), 'sync', '--force']) != 0:
476 print >> sys.stderr, ( 483 print >> sys.stderr, (
477 '(%s) `gclient sync` failed; proceeding anyway...' % sys.argv[0]) 484 '(%s) `gclient sync` failed; proceeding anyway...' % sys.argv[0])
478 os.execv(sys.executable, [sys.executable] + sys.argv + [skip_sync_arg]) 485 os.execv(sys.executable, [sys.executable] + sys.argv + [skip_sync_arg])
479 486
480 # Remove skip_sync_arg from arg list. Needed because twistd. 487 # Remove skip_sync_arg from arg list. Needed because twistd.
481 sys.argv.remove(skip_sync_arg) 488 sys.argv.remove(skip_sync_arg)
482 main() 489 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698