Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 | 7 |
| 8 """ | 8 """ |
| 9 submit_try: Submit a try request. | 9 submit_try: Submit a try request. |
| 10 | 10 |
| 11 This is a thin wrapper around the try request utilities in depot_tools which | 11 This is a thin wrapper around the try request utilities in depot_tools which |
| 12 adds some validation and supports both git and svn. | 12 adds some validation and supports both git and svn. |
| 13 """ | 13 """ |
| 14 | 14 |
| 15 | 15 |
| 16 from contextlib import closing | |
| 17 | |
| 18 import httplib | 16 import httplib |
| 19 import json | 17 import json |
| 20 import os | 18 import os |
| 21 import subprocess | 19 import subprocess |
| 20 import svn | |
| 22 import sys | 21 import sys |
| 23 import urllib2 | |
| 24 | 22 |
| 25 | 23 |
| 26 def GetGlobalVariables(): | 24 GLOBAL_VARIABLES = json.loads(svn.Svn.Cat('http://skia.googlecode.com/svn/' |
| 27 """ Retrieve a global variable from the global_variables.json file. """ | 25 'buildbot/site_config/' |
| 28 global_variables_file = ('http://skia.googlecode.com/svn/buildbot/' | 26 'global_variables.json')) |
| 29 'site_config/global_variables.json') | |
| 30 with closing(urllib2.urlopen(global_variables_file)) as f: | |
| 31 return json.load(f) | |
| 32 | |
| 33 | |
| 34 GLOBAL_VARIABLES = GetGlobalVariables() | |
| 35 | 27 |
| 36 | 28 |
| 37 def GetGlobalVariable(var_name): | 29 def GetGlobalVariable(var_name): |
| 38 return GLOBAL_VARIABLES[var_name]['value'] | 30 return GLOBAL_VARIABLES[var_name]['value'] |
| 39 | 31 |
| 40 | 32 |
| 41 # Alias which can be used to run a try on every builder. | 33 # Alias which can be used to run a try on every builder. |
| 42 ALL_BUILDERS = 'all' | 34 ALL_BUILDERS = 'all' |
| 43 | 35 |
| 44 # Contact information for the build master. | 36 # Contact information for the build master. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 72 return depot_tools_dir | 64 return depot_tools_dir |
| 73 | 65 |
| 74 | 66 |
| 75 def GetCheckoutRoot(is_svn=True): | 67 def GetCheckoutRoot(is_svn=True): |
| 76 """ Determine where the local checkout is rooted. | 68 """ Determine where the local checkout is rooted. |
| 77 | 69 |
| 78 is_svn: boolean; whether we're in an SVN checkout. If False, assume we're in | 70 is_svn: boolean; whether we're in an SVN checkout. If False, assume we're in |
| 79 a git checkout. | 71 a git checkout. |
| 80 """ | 72 """ |
| 81 if is_svn: | 73 if is_svn: |
| 82 svn_cmd = 'svn.bat' if os.name == 'nt' else 'svn' | 74 cmd = [svn.SVN, 'info'] |
|
epoger
2013/03/14 17:48:32
Given that the "info" command, unlike "svn cat", i
borenet
2013/03/14 18:25:18
Done.
| |
| 83 cmd = [svn_cmd, 'info'] | |
| 84 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, | 75 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
| 85 stderr=subprocess.STDOUT) | 76 stderr=subprocess.STDOUT) |
| 86 if proc.wait() != 0: | 77 if proc.wait() != 0: |
| 87 raise Exception('Couldn\'t find checkout root!') | 78 raise Exception('Couldn\'t find checkout root!') |
| 88 output = proc.communicate()[0].split('\n') | 79 output = proc.communicate()[0].split('\n') |
| 89 url = None | 80 url = None |
| 90 repo_root = None | 81 repo_root = None |
| 91 for line in output: | 82 for line in output: |
| 92 if line.startswith(REPO_ROOT_STR): | 83 if line.startswith(REPO_ROOT_STR): |
| 93 repo_root = line[len(REPO_ROOT_STR):].rstrip() | 84 repo_root = line[len(REPO_ROOT_STR):].rstrip() |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 | 264 |
| 274 # Parse and validate the command-line arguments. | 265 # Parse and validate the command-line arguments. |
| 275 args = ValidateArgs(sys.argv[1:], trybots=trybots, is_svn=is_svn) | 266 args = ValidateArgs(sys.argv[1:], trybots=trybots, is_svn=is_svn) |
| 276 | 267 |
| 277 # Submit the try request. | 268 # Submit the try request. |
| 278 SubmitTryRequest(args, is_svn=is_svn) | 269 SubmitTryRequest(args, is_svn=is_svn) |
| 279 | 270 |
| 280 | 271 |
| 281 if __name__ == '__main__': | 272 if __name__ == '__main__': |
| 282 sys.exit(main()) | 273 sys.exit(main()) |
| OLD | NEW |