Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 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 | 6 |
| 7 """Wrapper for updating and calling infra.git tools. | 7 """Wrapper for updating and calling infra.git tools. |
| 8 | 8 |
| 9 This tool does a two things: | 9 This tool does a two things: |
| 10 * Maintains a infra.git checkout pinned at "deployed" in the home dir | 10 * Maintains a infra.git checkout pinned at "deployed" in the home dir |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 | 49 |
| 50 subprocess.check_call( | 50 subprocess.check_call( |
| 51 ['git', 'fetch', 'origin'], cwd=INFRA_DIR, | 51 ['git', 'fetch', 'origin'], cwd=INFRA_DIR, |
| 52 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 52 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 53 origin_rev = get_git_rev(INFRA_DIR, 'origin/%s' % (branch,)) | 53 origin_rev = get_git_rev(INFRA_DIR, 'origin/%s' % (branch,)) |
| 54 return origin_rev != local_rev | 54 return origin_rev != local_rev |
| 55 | 55 |
| 56 | 56 |
| 57 def ensure_infra(branch): | 57 def ensure_infra(branch): |
| 58 """Ensures that infra.git is present in ~/.chrome-infra.""" | 58 """Ensures that infra.git is present in ~/.chrome-infra.""" |
| 59 print 'Fetching infra@%s into %s, may take a couple of minutes...' % ( | 59 sys.stderr.write( |
|
Ryan Tseng
2016/06/14 17:41:08
use print >>sys.stderr, "..."
Either that, or add
tandrii(chromium)
2016/06/14 18:09:40
Actually, the whole reason for using stderr.write
| |
| 60 branch, TARGET_DIR) | 60 'Fetching infra@%s into %s, may take a couple of minutes...' % ( |
| 61 branch, TARGET_DIR)) | |
| 62 sys.stderr.flush() | |
| 61 if not os.path.isdir(TARGET_DIR): | 63 if not os.path.isdir(TARGET_DIR): |
| 62 os.mkdir(TARGET_DIR) | 64 os.mkdir(TARGET_DIR) |
| 63 if not os.path.exists(os.path.join(TARGET_DIR, '.gclient')): | 65 if not os.path.exists(os.path.join(TARGET_DIR, '.gclient')): |
| 64 subprocess.check_call( | 66 subprocess.check_call( |
| 65 [sys.executable, os.path.join(SCRIPT_DIR, 'fetch.py'), 'infra'], | 67 [sys.executable, os.path.join(SCRIPT_DIR, 'fetch.py'), 'infra'], |
| 66 cwd=TARGET_DIR, | 68 cwd=TARGET_DIR, |
| 67 stdout=subprocess.PIPE) | 69 stdout=subprocess.PIPE) |
| 68 subprocess.check_call( | 70 subprocess.check_call( |
| 69 [sys.executable, GCLIENT, 'sync', '--revision', 'origin/%s' % (branch,)], | 71 [sys.executable, GCLIENT, 'sync', '--revision', 'origin/%s' % (branch,)], |
| 70 cwd=TARGET_DIR, | 72 cwd=TARGET_DIR, |
| 71 stdout=subprocess.PIPE) | 73 stdout=subprocess.PIPE) |
| 74 sys.stderr.write(' done.\n') | |
| 75 sys.stderr.flush() | |
| 72 | 76 |
| 73 | 77 |
| 74 def get_available_tools(): | 78 def get_available_tools(): |
| 75 tools = [] | 79 tools = [] |
| 76 starting = os.path.join(TARGET_DIR, 'infra', 'infra', 'tools') | 80 starting = os.path.join(TARGET_DIR, 'infra', 'infra', 'tools') |
| 77 for root, _, files in os.walk(starting): | 81 for root, _, files in os.walk(starting): |
| 78 if '__main__.py' in files: | 82 if '__main__.py' in files: |
| 79 tools.append(root[len(starting)+1:].replace(os.path.sep, '.')) | 83 tools.append(root[len(starting)+1:].replace(os.path.sep, '.')) |
| 80 return sorted(tools) | 84 return sorted(tools) |
| 81 | 85 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 111 args.args.pop(0) | 115 args.args.pop(0) |
| 112 if extras: | 116 if extras: |
| 113 args.args = extras + args.args | 117 args.args = extras + args.args |
| 114 | 118 |
| 115 if need_to_update(args.infra_branch): | 119 if need_to_update(args.infra_branch): |
| 116 ensure_infra(args.infra_branch) | 120 ensure_infra(args.infra_branch) |
| 117 return run(args.args) | 121 return run(args.args) |
| 118 | 122 |
| 119 if __name__ == '__main__': | 123 if __name__ == '__main__': |
| 120 sys.exit(main()) | 124 sys.exit(main()) |
| OLD | NEW |