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 return bool(revision and re.match(r'^\{.+\}$', str(revision))) |
| 118 |
| 119 |
| 120 def MakeDateRevision(date): |
| 121 """Returns a revision representing the latest revision before the given |
| 122 date.""" |
| 123 return "{" + date + "}" |
| 124 |
| 125 |
115 def SyntaxErrorToError(filename, e): | 126 def SyntaxErrorToError(filename, e): |
116 """Raises a gclient_utils.Error exception with the human readable message""" | 127 """Raises a gclient_utils.Error exception with the human readable message""" |
117 try: | 128 try: |
118 # Try to construct a human readable error message | 129 # Try to construct a human readable error message |
119 if filename: | 130 if filename: |
120 error_message = 'There is a syntax error in %s\n' % filename | 131 error_message = 'There is a syntax error in %s\n' % filename |
121 else: | 132 else: |
122 error_message = 'There is a syntax error\n' | 133 error_message = 'There is a syntax error\n' |
123 error_message += 'Line #%s, character %s: "%s"' % ( | 134 error_message += 'Line #%s, character %s: "%s"' % ( |
124 e.lineno, e.offset, re.sub(r'[\r\n]*$', '', e.text)) | 135 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) | 689 logging.info('Caught exception in thread %s' % self.item.name) |
679 logging.info(str(sys.exc_info())) | 690 logging.info(str(sys.exc_info())) |
680 work_queue.exceptions.put(sys.exc_info()) | 691 work_queue.exceptions.put(sys.exc_info()) |
681 logging.info('Task %s done' % self.item.name) | 692 logging.info('Task %s done' % self.item.name) |
682 | 693 |
683 work_queue.ready_cond.acquire() | 694 work_queue.ready_cond.acquire() |
684 try: | 695 try: |
685 work_queue.ready_cond.notifyAll() | 696 work_queue.ready_cond.notifyAll() |
686 finally: | 697 finally: |
687 work_queue.ready_cond.release() | 698 work_queue.ready_cond.release() |
OLD | NEW |