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) |
90 try: | 91 try: |
91 stderr = None | 92 stderr = None |
92 if not print_error: | 93 if not print_error: |
93 stderr = subprocess.PIPE | 94 stderr = subprocess.PIPE |
94 process = Popen(command, stdout=subprocess.PIPE, stderr=stderr, **kwargs) | 95 process = Popen(command, stdout=subprocess.PIPE, stderr=stderr, **kwargs) |
95 std_out, std_err = process.communicate() | 96 std_out, std_err = process.communicate() |
96 except OSError, e: | 97 except OSError, e: |
97 raise CheckCallError(command, kwargs.get('cwd', None), e.errno, None) | 98 raise CheckCallError(command, kwargs.get('cwd', None), e.errno, None) |
98 if process.returncode: | 99 if process.returncode: |
99 raise CheckCallError(command, kwargs.get('cwd', None), process.returncode, | 100 raise CheckCallError(command, kwargs.get('cwd', None), process.returncode, |
100 std_out, std_err) | 101 std_out, std_err) |
| 102 logging.info("CheckCall done") |
101 return std_out, std_err | 103 return std_out, std_err |
102 | 104 |
103 | 105 |
104 def SplitUrlRevision(url): | 106 def SplitUrlRevision(url): |
105 """Splits url and returns a two-tuple: url, rev""" | 107 """Splits url and returns a two-tuple: url, rev""" |
106 if url.startswith('ssh:'): | 108 if url.startswith('ssh:'): |
107 # Make sure ssh://user-name@example.com/~/test.git@stable works | 109 # Make sure ssh://user-name@example.com/~/test.git@stable works |
108 regex = r'(ssh://(?:[-\w]+@)?[-\w:\.]+/[-~\w\./]+)(?:@(.+))?' | 110 regex = r'(ssh://(?:[-\w]+@)?[-\w:\.]+/[-~\w\./]+)(?:@(.+))?' |
109 components = re.search(regex, url).groups() | 111 components = re.search(regex, url).groups() |
110 else: | 112 else: |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 logging.info('Caught exception in thread %s' % self.item.name) | 710 logging.info('Caught exception in thread %s' % self.item.name) |
709 logging.info(str(sys.exc_info())) | 711 logging.info(str(sys.exc_info())) |
710 work_queue.exceptions.put(sys.exc_info()) | 712 work_queue.exceptions.put(sys.exc_info()) |
711 logging.info('Task %s done' % self.item.name) | 713 logging.info('Task %s done' % self.item.name) |
712 | 714 |
713 work_queue.ready_cond.acquire() | 715 work_queue.ready_cond.acquire() |
714 try: | 716 try: |
715 work_queue.ready_cond.notifyAll() | 717 work_queue.ready_cond.notifyAll() |
716 finally: | 718 finally: |
717 work_queue.ready_cond.release() | 719 work_queue.ready_cond.release() |
OLD | NEW |