| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 codecs | 7 import codecs |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import pipes | 10 import pipes |
| 11 import Queue | 11 import Queue |
| 12 import re | 12 import re |
| 13 import socket | |
| 14 import stat | 13 import stat |
| 15 import subprocess | 14 import subprocess |
| 16 import sys | 15 import sys |
| 17 import tempfile | 16 import tempfile |
| 18 import threading | 17 import threading |
| 19 import time | 18 import time |
| 20 import urlparse | 19 import urlparse |
| 21 | 20 |
| 22 import subprocess2 | 21 import subprocess2 |
| 23 | 22 |
| 24 | 23 |
| 25 RETRY_MAX = 3 | 24 RETRY_MAX = 3 |
| 26 RETRY_INITIAL_SLEEP = 0.5 | 25 RETRY_INITIAL_SLEEP = 0.5 |
| 27 | 26 |
| 28 | 27 |
| 29 def enable_deletion_of_conflicting_checkouts(): | |
| 30 """Determines whether to enable new checkout deletion behavior. | |
| 31 | |
| 32 Initially, enables the experimental functionality on a small set of | |
| 33 bots. | |
| 34 """ | |
| 35 # TODO(borenet): Remove this hack as soon as we've verified that it | |
| 36 # doesn't cause the bots to break. | |
| 37 if not os.environ.get('CHROME_HEADLESS'): | |
| 38 return False | |
| 39 return socket.gethostname() in ('vm859-m1', 'BUILD1-M1', | |
| 40 'vm630-m1.golo.chromium.org') | |
| 41 | |
| 42 | |
| 43 class Error(Exception): | 28 class Error(Exception): |
| 44 """gclient exception class.""" | 29 """gclient exception class.""" |
| 45 def __init__(self, msg, *args, **kwargs): | 30 def __init__(self, msg, *args, **kwargs): |
| 46 index = getattr(threading.currentThread(), 'index', 0) | 31 index = getattr(threading.currentThread(), 'index', 0) |
| 47 if index: | 32 if index: |
| 48 msg = '\n'.join('%d> %s' % (index, l) for l in msg.splitlines()) | 33 msg = '\n'.join('%d> %s' % (index, l) for l in msg.splitlines()) |
| 49 super(Error, self).__init__(msg, *args, **kwargs) | 34 super(Error, self).__init__(msg, *args, **kwargs) |
| 50 | 35 |
| 51 | 36 |
| 52 def SplitUrlRevision(url): | 37 def SplitUrlRevision(url): |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 | 950 |
| 966 Python on OSX 10.6 raises a NotImplementedError exception. | 951 Python on OSX 10.6 raises a NotImplementedError exception. |
| 967 """ | 952 """ |
| 968 try: | 953 try: |
| 969 import multiprocessing | 954 import multiprocessing |
| 970 return multiprocessing.cpu_count() | 955 return multiprocessing.cpu_count() |
| 971 except: # pylint: disable=W0702 | 956 except: # pylint: disable=W0702 |
| 972 # Mac OS 10.6 only | 957 # Mac OS 10.6 only |
| 973 # pylint: disable=E1101 | 958 # pylint: disable=E1101 |
| 974 return int(os.sysconf('SC_NPROCESSORS_ONLN')) | 959 return int(os.sysconf('SC_NPROCESSORS_ONLN')) |
| OLD | NEW |