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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return subprocess.Popen(args, **kwargs) | 77 return subprocess.Popen(args, **kwargs) |
78 except OSError, e: | 78 except OSError, e: |
79 if e.errno == errno.EAGAIN and sys.platform == 'cygwin': | 79 if e.errno == errno.EAGAIN and sys.platform == 'cygwin': |
80 raise Error( | 80 raise Error( |
81 'Visit ' | 81 'Visit ' |
82 'http://code.google.com/p/chromium/wiki/CygwinDllRemappingFailure to ' | 82 'http://code.google.com/p/chromium/wiki/CygwinDllRemappingFailure to ' |
83 'learn how to fix this error; you need to rebase your cygwin dlls') | 83 'learn how to fix this error; you need to rebase your cygwin dlls') |
84 raise | 84 raise |
85 | 85 |
86 | 86 |
87 def CheckCall(command, cwd=None, print_error=True): | 87 def CheckCall(command, print_error=True, **kwargs): |
88 """Similar subprocess.check_call() but redirects stdout and | 88 """Similar subprocess.check_call() but redirects stdout and |
89 returns (stdout, stderr). | 89 returns (stdout, stderr). |
90 | 90 |
91 Works on python 2.4 | 91 Works on python 2.4 |
92 """ | 92 """ |
93 try: | 93 try: |
94 stderr = None | 94 stderr = None |
95 if not print_error: | 95 if not print_error: |
96 stderr = subprocess.PIPE | 96 stderr = subprocess.PIPE |
97 process = Popen(command, cwd=cwd, stdout=subprocess.PIPE, stderr=stderr) | 97 process = Popen(command, stdout=subprocess.PIPE, stderr=stderr, **kwargs) |
98 std_out, std_err = process.communicate() | 98 std_out, std_err = process.communicate() |
99 except OSError, e: | 99 except OSError, e: |
100 raise CheckCallError(command, cwd, e.errno, None) | 100 raise CheckCallError(command, kwargs.get('cwd', None), e.errno, None) |
101 if process.returncode: | 101 if process.returncode: |
102 raise CheckCallError(command, cwd, process.returncode, std_out, std_err) | 102 raise CheckCallError(command, kwargs.get('cwd', None), process.returncode, |
| 103 std_out, std_err) |
103 return std_out, std_err | 104 return std_out, std_err |
104 | 105 |
105 | 106 |
106 def SplitUrlRevision(url): | 107 def SplitUrlRevision(url): |
107 """Splits url and returns a two-tuple: url, rev""" | 108 """Splits url and returns a two-tuple: url, rev""" |
108 if url.startswith('ssh:'): | 109 if url.startswith('ssh:'): |
109 # Make sure ssh://test@example.com/test.git@stable works | 110 # Make sure ssh://test@example.com/test.git@stable works |
110 regex = r'(ssh://(?:[\w]+@)?[-\w:\.]+/[-\w\./]+)(?:@(.+))?' | 111 regex = r'(ssh://(?:[\w]+@)?[-\w:\.]+/[-\w\./]+)(?:@(.+))?' |
111 components = re.search(regex, url).groups() | 112 components = re.search(regex, url).groups() |
112 else: | 113 else: |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 logging.info('Caught exception in thread %s' % self.item.name) | 705 logging.info('Caught exception in thread %s' % self.item.name) |
705 logging.info(str(sys.exc_info())) | 706 logging.info(str(sys.exc_info())) |
706 work_queue.exceptions.put(sys.exc_info()) | 707 work_queue.exceptions.put(sys.exc_info()) |
707 logging.info('Task %s done' % self.item.name) | 708 logging.info('Task %s done' % self.item.name) |
708 | 709 |
709 work_queue.ready_cond.acquire() | 710 work_queue.ready_cond.acquire() |
710 try: | 711 try: |
711 work_queue.ready_cond.notifyAll() | 712 work_queue.ready_cond.notifyAll() |
712 finally: | 713 finally: |
713 work_queue.ready_cond.release() | 714 work_queue.ready_cond.release() |
OLD | NEW |