Chromium Code Reviews| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 # Make sure ssh://user-name@example.com/~/test.git@stable works | 105 # Make sure ssh://user-name@example.com/~/test.git@stable works |
| 106 regex = r'(ssh://(?:[-\w]+@)?[-\w:\.]+/[-~\w\./]+)(?:@(.+))?' | 106 regex = r'(ssh://(?:[-\w]+@)?[-\w:\.]+/[-~\w\./]+)(?:@(.+))?' |
| 107 components = re.search(regex, url).groups() | 107 components = re.search(regex, url).groups() |
| 108 else: | 108 else: |
| 109 components = url.split('@', 1) | 109 components = url.split('@', 1) |
| 110 if len(components) == 1: | 110 if len(components) == 1: |
| 111 components += [None] | 111 components += [None] |
| 112 return tuple(components) | 112 return tuple(components) |
| 113 | 113 |
| 114 | 114 |
| 115 def IsDateRevision(revision): | |
| 116 """Returns true if the given revision is of the form "{ ... }".""" | |
| 117 if revision is None: | |
|
M-A Ruel
2011/04/21 23:54:58
return bool(revision and re.match(r'^\{.+\}$', str
Florian Loitsch
2011/04/26 12:53:06
Done.
| |
| 118 return False | |
| 119 return bool(re.match(r'^\{.+\}$', str(revision))) | |
| 120 | |
| 121 | |
| 122 def MakeDateRevision(date): | |
| 123 """Returns a revision representing the latest revision before the given | |
| 124 date.""" | |
| 125 return "{" + date + "}" | |
| 126 | |
| 127 | |
| 115 def SyntaxErrorToError(filename, e): | 128 def SyntaxErrorToError(filename, e): |
| 116 """Raises a gclient_utils.Error exception with the human readable message""" | 129 """Raises a gclient_utils.Error exception with the human readable message""" |
| 117 try: | 130 try: |
| 118 # Try to construct a human readable error message | 131 # Try to construct a human readable error message |
| 119 if filename: | 132 if filename: |
| 120 error_message = 'There is a syntax error in %s\n' % filename | 133 error_message = 'There is a syntax error in %s\n' % filename |
| 121 else: | 134 else: |
| 122 error_message = 'There is a syntax error\n' | 135 error_message = 'There is a syntax error\n' |
| 123 error_message += 'Line #%s, character %s: "%s"' % ( | 136 error_message += 'Line #%s, character %s: "%s"' % ( |
| 124 e.lineno, e.offset, re.sub(r'[\r\n]*$', '', e.text)) | 137 e.lineno, e.offset, re.sub(r'[\r\n]*$', '', e.text)) |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 logging.info('Caught exception in thread %s' % self.item.name) | 691 logging.info('Caught exception in thread %s' % self.item.name) |
| 679 logging.info(str(sys.exc_info())) | 692 logging.info(str(sys.exc_info())) |
| 680 work_queue.exceptions.put(sys.exc_info()) | 693 work_queue.exceptions.put(sys.exc_info()) |
| 681 logging.info('Task %s done' % self.item.name) | 694 logging.info('Task %s done' % self.item.name) |
| 682 | 695 |
| 683 work_queue.ready_cond.acquire() | 696 work_queue.ready_cond.acquire() |
| 684 try: | 697 try: |
| 685 work_queue.ready_cond.notifyAll() | 698 work_queue.ready_cond.notifyAll() |
| 686 finally: | 699 finally: |
| 687 work_queue.ready_cond.release() | 700 work_queue.ready_cond.release() |
| OLD | NEW |