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 25 matching lines...) Expand all Loading... |
36 """CheckCall() returned non-0.""" | 36 """CheckCall() returned non-0.""" |
37 def __init__(self, command, cwd, returncode, stdout, stderr=None): | 37 def __init__(self, command, cwd, returncode, stdout, stderr=None): |
38 OSError.__init__(self, command, cwd, returncode, stdout, stderr) | 38 OSError.__init__(self, command, cwd, returncode, stdout, stderr) |
39 Error.__init__(self) | 39 Error.__init__(self) |
40 self.command = command | 40 self.command = command |
41 self.cwd = cwd | 41 self.cwd = cwd |
42 self.returncode = returncode | 42 self.returncode = returncode |
43 self.stdout = stdout | 43 self.stdout = stdout |
44 self.stderr = stderr | 44 self.stderr = stderr |
45 | 45 |
| 46 def __str__(self): |
| 47 out = ' '.join(self.command) |
| 48 if self.cwd: |
| 49 out += ' in ' + self.cwd |
| 50 if self.returncode is not None: |
| 51 out += ' returned %d' % self.returncode |
| 52 if self.stdout is not None: |
| 53 out += '\nstdout: %s\n' % self.stdout |
| 54 if self.stderr is not None: |
| 55 out += '\nstderr: %s\n' % self.stderr |
| 56 return out |
| 57 |
46 | 58 |
47 def Popen(args, **kwargs): | 59 def Popen(args, **kwargs): |
48 """Calls subprocess.Popen() with hacks to work around certain behaviors. | 60 """Calls subprocess.Popen() with hacks to work around certain behaviors. |
49 | 61 |
50 Ensure English outpout for svn and make it work reliably on Windows. | 62 Ensure English outpout for svn and make it work reliably on Windows. |
51 """ | 63 """ |
52 logging.debug(u'%s, cwd=%s' % (u' '.join(args), kwargs.get('cwd', ''))) | 64 logging.debug(u'%s, cwd=%s' % (u' '.join(args), kwargs.get('cwd', ''))) |
53 if not 'env' in kwargs: | 65 if not 'env' in kwargs: |
54 # It's easier to parse the stdout if it is always in English. | 66 # It's easier to parse the stdout if it is always in English. |
55 kwargs['env'] = os.environ.copy() | 67 kwargs['env'] = os.environ.copy() |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 if (time.time() - last_flushed_at) > 10: | 335 if (time.time() - last_flushed_at) > 10: |
324 last_flushed_at = time.time() | 336 last_flushed_at = time.time() |
325 stdout.flush() | 337 stdout.flush() |
326 in_byte = kid.stdout.read(1) | 338 in_byte = kid.stdout.read(1) |
327 # Flush the rest of buffered output. This is only an issue with | 339 # Flush the rest of buffered output. This is only an issue with |
328 # stdout/stderr not ending with a \n. | 340 # stdout/stderr not ending with a \n. |
329 if len(in_line): | 341 if len(in_line): |
330 filter_fn(in_line) | 342 filter_fn(in_line) |
331 rv = kid.wait() | 343 rv = kid.wait() |
332 if rv: | 344 if rv: |
333 raise Error('failed to run command: %s' % ' '.join(args)) | 345 raise CheckCallError(args, kwargs.get('cwd', None), rv, None) |
334 return 0 | 346 return 0 |
335 | 347 |
336 | 348 |
337 def FindGclientRoot(from_dir, filename='.gclient'): | 349 def FindGclientRoot(from_dir, filename='.gclient'): |
338 """Tries to find the gclient root.""" | 350 """Tries to find the gclient root.""" |
339 path = os.path.realpath(from_dir) | 351 path = os.path.realpath(from_dir) |
340 while not os.path.exists(os.path.join(path, filename)): | 352 while not os.path.exists(os.path.join(path, filename)): |
341 split_path = os.path.split(path) | 353 split_path = os.path.split(path) |
342 if not split_path[1]: | 354 if not split_path[1]: |
343 return None | 355 return None |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 if exception: | 537 if exception: |
526 self.parent.exceptions.append(exception) | 538 self.parent.exceptions.append(exception) |
527 if self.parent.progress: | 539 if self.parent.progress: |
528 self.parent.progress.update(1) | 540 self.parent.progress.update(1) |
529 assert not self.item.name in self.parent.ran | 541 assert not self.item.name in self.parent.ran |
530 if not self.item.name in self.parent.ran: | 542 if not self.item.name in self.parent.ran: |
531 self.parent.ran.append(self.item.name) | 543 self.parent.ran.append(self.item.name) |
532 finally: | 544 finally: |
533 self.parent.ready_cond.notifyAll() | 545 self.parent.ready_cond.notifyAll() |
534 self.parent.ready_cond.release() | 546 self.parent.ready_cond.release() |
OLD | NEW |