| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Generic utils.""" | 5 """Generic utils.""" |
| 6 | 6 |
| 7 import errno | 7 import errno |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import Queue | 10 import Queue |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 'learn how to fix this error; you need to rebase your cygwin dlls') | 80 'learn how to fix this error; you need to rebase your cygwin dlls') |
| 81 raise | 81 raise |
| 82 | 82 |
| 83 | 83 |
| 84 def CheckCall(command, print_error=True, **kwargs): | 84 def CheckCall(command, print_error=True, **kwargs): |
| 85 """Similar subprocess.check_call() but redirects stdout and | 85 """Similar subprocess.check_call() but redirects stdout and |
| 86 returns (stdout, stderr). | 86 returns (stdout, stderr). |
| 87 | 87 |
| 88 Works on python 2.4 | 88 Works on python 2.4 |
| 89 """ | 89 """ |
| 90 logging.info("CheckCall(%s)" % command) | |
| 91 try: | 90 try: |
| 92 stderr = None | 91 stderr = None |
| 93 if not print_error: | 92 if not print_error: |
| 94 stderr = subprocess.PIPE | 93 stderr = subprocess.PIPE |
| 95 process = Popen(command, stdout=subprocess.PIPE, stderr=stderr, **kwargs) | 94 process = Popen(command, stdout=subprocess.PIPE, stderr=stderr, **kwargs) |
| 96 std_out, std_err = process.communicate() | 95 std_out, std_err = process.communicate() |
| 97 except OSError, e: | 96 except OSError, e: |
| 98 raise CheckCallError(command, kwargs.get('cwd', None), e.errno, None) | 97 raise CheckCallError(command, kwargs.get('cwd', None), e.errno, None) |
| 99 if process.returncode: | 98 if process.returncode: |
| 100 raise CheckCallError(command, kwargs.get('cwd', None), process.returncode, | 99 raise CheckCallError(command, kwargs.get('cwd', None), process.returncode, |
| 101 std_out, std_err) | 100 std_out, std_err) |
| 102 logging.info("CheckCall done") | |
| 103 return std_out, std_err | 101 return std_out, std_err |
| 104 | 102 |
| 105 | 103 |
| 106 def SplitUrlRevision(url): | 104 def SplitUrlRevision(url): |
| 107 """Splits url and returns a two-tuple: url, rev""" | 105 """Splits url and returns a two-tuple: url, rev""" |
| 108 if url.startswith('ssh:'): | 106 if url.startswith('ssh:'): |
| 109 # Make sure ssh://user-name@example.com/~/test.git@stable works | 107 # Make sure ssh://user-name@example.com/~/test.git@stable works |
| 110 regex = r'(ssh://(?:[-\w]+@)?[-\w:\.]+/[-~\w\./]+)(?:@(.+))?' | 108 regex = r'(ssh://(?:[-\w]+@)?[-\w:\.]+/[-~\w\./]+)(?:@(.+))?' |
| 111 components = re.search(regex, url).groups() | 109 components = re.search(regex, url).groups() |
| 112 else: | 110 else: |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 logging.info('Caught exception in thread %s' % self.item.name) | 708 logging.info('Caught exception in thread %s' % self.item.name) |
| 711 logging.info(str(sys.exc_info())) | 709 logging.info(str(sys.exc_info())) |
| 712 work_queue.exceptions.put(sys.exc_info()) | 710 work_queue.exceptions.put(sys.exc_info()) |
| 713 logging.info('Task %s done' % self.item.name) | 711 logging.info('Task %s done' % self.item.name) |
| 714 | 712 |
| 715 work_queue.ready_cond.acquire() | 713 work_queue.ready_cond.acquire() |
| 716 try: | 714 try: |
| 717 work_queue.ready_cond.notifyAll() | 715 work_queue.ready_cond.notifyAll() |
| 718 finally: | 716 finally: |
| 719 work_queue.ready_cond.release() | 717 work_queue.ready_cond.release() |
| OLD | NEW |