OLD | NEW |
1 # Copyright 2009 Google Inc. All Rights Reserved. | 1 # Copyright 2009 Google Inc. All Rights Reserved. |
2 # | 2 # |
3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
6 # | 6 # |
7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
8 # | 8 # |
9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 def CheckCall(command, cwd=None, print_error=True): | 42 def CheckCall(command, cwd=None, print_error=True): |
43 """Like subprocess.check_call() but returns stdout. | 43 """Like subprocess.check_call() but returns stdout. |
44 | 44 |
45 Works on python 2.4 | 45 Works on python 2.4 |
46 """ | 46 """ |
47 logging.debug('%s, cwd=%s' % (str(command), str(cwd))) | 47 logging.debug('%s, cwd=%s' % (str(command), str(cwd))) |
48 try: | 48 try: |
49 stderr = None | 49 stderr = None |
50 if not print_error: | 50 if not print_error: |
51 stderr = subprocess.PIPE | 51 stderr = subprocess.PIPE |
| 52 env = os.environ.copy() |
| 53 env['LANGUAGE'] = 'en' |
52 process = subprocess.Popen(command, cwd=cwd, | 54 process = subprocess.Popen(command, cwd=cwd, |
53 shell=sys.platform.startswith('win'), | 55 shell=sys.platform.startswith('win'), |
54 stdout=subprocess.PIPE, | 56 stdout=subprocess.PIPE, |
55 stderr=stderr) | 57 stderr=stderr, |
| 58 env=env) |
56 std_out, std_err = process.communicate() | 59 std_out, std_err = process.communicate() |
57 except OSError, e: | 60 except OSError, e: |
58 raise CheckCallError(command, cwd, e.errno, None) | 61 raise CheckCallError(command, cwd, e.errno, None) |
59 if process.returncode: | 62 if process.returncode: |
60 raise CheckCallError(command, cwd, process.returncode, std_out, std_err) | 63 raise CheckCallError(command, cwd, process.returncode, std_out, std_err) |
61 return std_out, std_err | 64 return std_out, std_err |
62 | 65 |
63 | 66 |
64 def SplitUrlRevision(url): | 67 def SplitUrlRevision(url): |
65 """Splits url and returns a two-tuple: url, rev""" | 68 """Splits url and returns a two-tuple: url, rev""" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 trimmed. | 268 trimmed. |
266 | 269 |
267 If the command fails, as indicated by a nonzero exit status, gclient will | 270 If the command fails, as indicated by a nonzero exit status, gclient will |
268 exit with an exit status of fail_status. If fail_status is None (the | 271 exit with an exit status of fail_status. If fail_status is None (the |
269 default), gclient will raise an Error exception. | 272 default), gclient will raise an Error exception. |
270 """ | 273 """ |
271 logging.debug(command) | 274 logging.debug(command) |
272 if print_messages: | 275 if print_messages: |
273 print('\n________ running \'%s\' in \'%s\'' | 276 print('\n________ running \'%s\' in \'%s\'' |
274 % (' '.join(command), in_directory)) | 277 % (' '.join(command), in_directory)) |
| 278 env = os.environ.copy() |
| 279 env['LANGUAGE'] = 'en' |
275 | 280 |
276 # *Sigh*: Windows needs shell=True, or else it won't search %PATH% for the | 281 # *Sigh*: Windows needs shell=True, or else it won't search %PATH% for the |
277 # executable, but shell=True makes subprocess on Linux fail when it's called | 282 # executable, but shell=True makes subprocess on Linux fail when it's called |
278 # with a list because it only tries to execute the first item in the list. | 283 # with a list because it only tries to execute the first item in the list. |
279 kid = subprocess.Popen(command, bufsize=0, cwd=in_directory, | 284 kid = subprocess.Popen(command, bufsize=0, cwd=in_directory, |
280 shell=(sys.platform == 'win32'), stdout=subprocess.PIPE, | 285 shell=(sys.platform == 'win32'), stdout=subprocess.PIPE, |
281 stderr=subprocess.STDOUT) | 286 stderr=subprocess.STDOUT, env=env) |
282 | 287 |
283 # Do a flush of sys.stdout before we begin reading from the subprocess's | 288 # Do a flush of sys.stdout before we begin reading from the subprocess's |
284 # stdout. | 289 # stdout. |
285 last_flushed_at = time.time() | 290 last_flushed_at = time.time() |
286 sys.stdout.flush() | 291 sys.stdout.flush() |
287 | 292 |
288 # Also, we need to forward stdout to prevent weird re-ordering of output. | 293 # Also, we need to forward stdout to prevent weird re-ordering of output. |
289 # This has to be done on a per byte basis to make sure it is not buffered: | 294 # This has to be done on a per byte basis to make sure it is not buffered: |
290 # normally buffering is done for each line, but if svn requests input, no | 295 # normally buffering is done for each line, but if svn requests input, no |
291 # end-of-line character is output after the prompt and it would not show up. | 296 # end-of-line character is output after the prompt and it would not show up. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 if exception: | 520 if exception: |
516 self.parent.exceptions.append(exception) | 521 self.parent.exceptions.append(exception) |
517 if self.parent.progress: | 522 if self.parent.progress: |
518 self.parent.progress.update(1) | 523 self.parent.progress.update(1) |
519 assert not self.item.name in self.parent.ran | 524 assert not self.item.name in self.parent.ran |
520 if not self.item.name in self.parent.ran: | 525 if not self.item.name in self.parent.ran: |
521 self.parent.ran.append(self.item.name) | 526 self.parent.ran.append(self.item.name) |
522 finally: | 527 finally: |
523 self.parent.ready_cond.notifyAll() | 528 self.parent.ready_cond.notifyAll() |
524 self.parent.ready_cond.release() | 529 self.parent.ready_cond.release() |
OLD | NEW |