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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 print >> sys.stderr, msg | 201 print >> sys.stderr, msg |
202 | 202 |
203 | 203 |
204 def ErrorExit(msg): | 204 def ErrorExit(msg): |
205 print >> sys.stderr, msg | 205 print >> sys.stderr, msg |
206 sys.exit(1) | 206 sys.exit(1) |
207 | 207 |
208 | 208 |
209 def RunShellWithReturnCode(command, print_output=False): | 209 def RunShellWithReturnCode(command, print_output=False): |
210 """Executes a command and returns the output and the return code.""" | 210 """Executes a command and returns the output and the return code.""" |
211 # Use a shell for subcommands on Windows to get a PATH search, and because svn | 211 p = gclient_utils.Popen(command, stdout=subprocess.PIPE, |
212 # may be a batch file. | 212 stderr=subprocess.STDOUT, universal_newlines=True) |
213 use_shell = sys.platform.startswith("win") | |
214 env = os.environ.copy() | |
215 env['LANGUAGE'] = 'en' | |
216 p = subprocess.Popen(command, stdout=subprocess.PIPE, | |
217 stderr=subprocess.STDOUT, shell=use_shell, env=env, | |
218 universal_newlines=True) | |
219 if print_output: | 213 if print_output: |
220 output_array = [] | 214 output_array = [] |
221 while True: | 215 while True: |
222 line = p.stdout.readline() | 216 line = p.stdout.readline() |
223 if not line: | 217 if not line: |
224 break | 218 break |
225 if print_output: | 219 if print_output: |
226 print line.strip('\n') | 220 print line.strip('\n') |
227 output_array.append(line) | 221 output_array.append(line) |
228 output = "".join(output_array) | 222 output = "".join(output_array) |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 if command: | 1314 if command: |
1321 return command(argv[1:]) | 1315 return command(argv[1:]) |
1322 # Unknown command, try to pass that to svn | 1316 # Unknown command, try to pass that to svn |
1323 return CMDpassthru(argv) | 1317 return CMDpassthru(argv) |
1324 except gclient_utils.Error, e: | 1318 except gclient_utils.Error, e: |
1325 print('Got an exception') | 1319 print('Got an exception') |
1326 print(str(e)) | 1320 print(str(e)) |
1327 | 1321 |
1328 if __name__ == "__main__": | 1322 if __name__ == "__main__": |
1329 sys.exit(main(sys.argv[1:])) | 1323 sys.exit(main(sys.argv[1:])) |
OLD | NEW |