| 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 |
| 13 import stat | 14 import stat |
| 14 import subprocess | 15 import subprocess |
| 15 import sys | 16 import sys |
| 16 import tempfile | 17 import tempfile |
| 17 import threading | 18 import threading |
| 18 import time | 19 import time |
| 19 import urlparse | 20 import urlparse |
| 20 | 21 |
| 21 import subprocess2 | 22 import subprocess2 |
| 22 | 23 |
| 23 | 24 |
| 24 RETRY_MAX = 3 | 25 RETRY_MAX = 3 |
| 25 RETRY_INITIAL_SLEEP = 0.5 | 26 RETRY_INITIAL_SLEEP = 0.5 |
| 26 | 27 |
| 27 | 28 |
| 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 |
| 28 class Error(Exception): | 43 class Error(Exception): |
| 29 """gclient exception class.""" | 44 """gclient exception class.""" |
| 30 def __init__(self, msg, *args, **kwargs): | 45 def __init__(self, msg, *args, **kwargs): |
| 31 index = getattr(threading.currentThread(), 'index', 0) | 46 index = getattr(threading.currentThread(), 'index', 0) |
| 32 if index: | 47 if index: |
| 33 msg = '\n'.join('%d> %s' % (index, l) for l in msg.splitlines()) | 48 msg = '\n'.join('%d> %s' % (index, l) for l in msg.splitlines()) |
| 34 super(Error, self).__init__(msg, *args, **kwargs) | 49 super(Error, self).__init__(msg, *args, **kwargs) |
| 35 | 50 |
| 36 | 51 |
| 37 def SplitUrlRevision(url): | 52 def SplitUrlRevision(url): |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 | 928 |
| 914 Python on OSX 10.6 raises a NotImplementedError exception. | 929 Python on OSX 10.6 raises a NotImplementedError exception. |
| 915 """ | 930 """ |
| 916 try: | 931 try: |
| 917 import multiprocessing | 932 import multiprocessing |
| 918 return multiprocessing.cpu_count() | 933 return multiprocessing.cpu_count() |
| 919 except: # pylint: disable=W0702 | 934 except: # pylint: disable=W0702 |
| 920 # Mac OS 10.6 only | 935 # Mac OS 10.6 only |
| 921 # pylint: disable=E1101 | 936 # pylint: disable=E1101 |
| 922 return int(os.sysconf('SC_NPROCESSORS_ONLN')) | 937 return int(os.sysconf('SC_NPROCESSORS_ONLN')) |
| OLD | NEW |