| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 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 script around Rietveld's upload.py that simplifies working with groups | 7 Wrapper script around Rietveld's upload.py that simplifies working with groups |
| 8 of files. | 8 of files. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 print >> sys.stderr, msg | 197 print >> sys.stderr, msg |
| 198 | 198 |
| 199 | 199 |
| 200 def ErrorExit(msg): | 200 def ErrorExit(msg): |
| 201 print >> sys.stderr, msg | 201 print >> sys.stderr, msg |
| 202 sys.exit(1) | 202 sys.exit(1) |
| 203 | 203 |
| 204 | 204 |
| 205 def RunShellWithReturnCode(command, print_output=False): | 205 def RunShellWithReturnCode(command, print_output=False): |
| 206 """Executes a command and returns the output and the return code.""" | 206 """Executes a command and returns the output and the return code.""" |
| 207 # Use a shell for subcommands on Windows to get a PATH search, and because svn | 207 p = gclient_utils.Popen(command, stdout=subprocess.PIPE, |
| 208 # may be a batch file. | 208 stderr=subprocess.STDOUT, universal_newlines=True) |
| 209 use_shell = sys.platform.startswith("win") | |
| 210 env = os.environ.copy() | |
| 211 env['LANGUAGE'] = 'en' | |
| 212 p = subprocess.Popen(command, stdout=subprocess.PIPE, | |
| 213 stderr=subprocess.STDOUT, shell=use_shell, env=env, | |
| 214 universal_newlines=True) | |
| 215 if print_output: | 209 if print_output: |
| 216 output_array = [] | 210 output_array = [] |
| 217 while True: | 211 while True: |
| 218 line = p.stdout.readline() | 212 line = p.stdout.readline() |
| 219 if not line: | 213 if not line: |
| 220 break | 214 break |
| 221 if print_output: | 215 if print_output: |
| 222 print line.strip('\n') | 216 print line.strip('\n') |
| 223 output_array.append(line) | 217 output_array.append(line) |
| 224 output = "".join(output_array) | 218 output = "".join(output_array) |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 if command: | 1310 if command: |
| 1317 return command(argv[1:]) | 1311 return command(argv[1:]) |
| 1318 # Unknown command, try to pass that to svn | 1312 # Unknown command, try to pass that to svn |
| 1319 return CMDpassthru(argv) | 1313 return CMDpassthru(argv) |
| 1320 except gclient_utils.Error, e: | 1314 except gclient_utils.Error, e: |
| 1321 print('Got an exception') | 1315 print('Got an exception') |
| 1322 print(str(e)) | 1316 print(str(e)) |
| 1323 | 1317 |
| 1324 if __name__ == "__main__": | 1318 if __name__ == "__main__": |
| 1325 sys.exit(main(sys.argv[1:])) | 1319 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |