| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python -u |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 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 """This allows easy execution of a recipe (scripts/slave/recipes, etc.) | 6 """This allows easy execution of a recipe (scripts/slave/recipes, etc.) |
| 7 without buildbot. | 7 without buildbot. |
| 8 | 8 |
| 9 This is currently useful for testing recipes locally while developing them. | 9 This is currently useful for testing recipes locally while developing them. |
| 10 | 10 |
| 11 Example: | 11 Example: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 import json | 24 import json |
| 25 import os | 25 import os |
| 26 import subprocess | 26 import subprocess |
| 27 import sys | 27 import sys |
| 28 | 28 |
| 29 SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__)) | 29 SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__)) |
| 30 ROOT_PATH = os.path.abspath(os.path.join(SCRIPT_PATH, os.pardir, os.pardir)) | 30 ROOT_PATH = os.path.abspath(os.path.join(SCRIPT_PATH, os.pardir, os.pardir)) |
| 31 SLAVE_DIR = os.path.join(ROOT_PATH, 'slave', 'fake_slave', 'build') | 31 SLAVE_DIR = os.path.join(ROOT_PATH, 'slave', 'fake_slave', 'build') |
| 32 | 32 |
| 33 RUNIT = os.path.join(SCRIPT_PATH, 'runit.sh') | 33 RUNIT = os.path.join(SCRIPT_PATH, 'runit.py') |
| 34 ANNOTATED_RUN = os.path.join(ROOT_PATH, 'scripts', 'slave', 'annotated_run.py') | 34 ANNOTATED_RUN = os.path.join(ROOT_PATH, 'scripts', 'slave', 'annotated_run.py') |
| 35 | 35 |
| 36 def usage(msg=None): | 36 def usage(msg=None): |
| 37 """Print help and exit.""" | 37 """Print help and exit.""" |
| 38 if msg: | 38 if msg: |
| 39 print 'Error:', msg | 39 print 'Error:', msg |
| 40 | 40 |
| 41 print ( | 41 print ( |
| 42 """ | 42 """ |
| 43 usage: %s <recipe_name> [<factory_property=value>*] [-- <build_property=value>*] | 43 usage: %s <recipe_name> [<factory_property=value>*] [-- <build_property=value>*] |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 def main(argv): | 86 def main(argv): |
| 87 fp, bp = parse_args(argv) | 87 fp, bp = parse_args(argv) |
| 88 | 88 |
| 89 if not os.path.exists(SLAVE_DIR): | 89 if not os.path.exists(SLAVE_DIR): |
| 90 os.makedirs(SLAVE_DIR) | 90 os.makedirs(SLAVE_DIR) |
| 91 | 91 |
| 92 env = os.environ.copy() | 92 env = os.environ.copy() |
| 93 env['RUN_SLAVE_UPDATED_SCRIPTS'] = '1' | 93 env['RUN_SLAVE_UPDATED_SCRIPTS'] = '1' |
| 94 env['PYTHONUNBUFFERED'] = '1' | 94 env['PYTHONUNBUFFERED'] = '1' |
| 95 return subprocess.call( | 95 return subprocess.call( |
| 96 [RUNIT, ANNOTATED_RUN, | 96 ['python', '-u', RUNIT, 'python', '-u', ANNOTATED_RUN, |
| 97 '--keep-stdin', # so that pdb works for local execution | 97 '--keep-stdin', # so that pdb works for local execution |
| 98 '--factory-properties', json.dumps(fp), | 98 '--factory-properties', json.dumps(fp), |
| 99 '--build-properties', json.dumps(bp)], | 99 '--build-properties', json.dumps(bp)], |
| 100 cwd=SLAVE_DIR, | 100 cwd=SLAVE_DIR, |
| 101 env=env) | 101 env=env) |
| 102 | 102 |
| 103 | 103 |
| 104 if __name__ == '__main__': | 104 if __name__ == '__main__': |
| 105 sys.exit(main(sys.argv)) | 105 sys.exit(main(sys.argv)) |
| OLD | NEW |