Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(648)

Side by Side Diff: gclient_utils.py

Issue 15792004: Add job prefix to error messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: tweak Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Queue 10 import Queue
11 import re 11 import re
12 import stat 12 import stat
13 import subprocess 13 import subprocess
14 import sys 14 import sys
15 import tempfile 15 import tempfile
16 import threading 16 import threading
17 import time 17 import time
18 import urlparse 18 import urlparse
19 19
20 import subprocess2 20 import subprocess2
21 21
22 22
23 class Error(Exception): 23 class Error(Exception):
24 """gclient exception class.""" 24 """gclient exception class."""
25 pass 25 def __init__(self, msg, *args, **kwargs):
26 26 index = getattr(threading.currentThread(), 'index', 0)
27 if index:
28 msg = '\n'.join('%d> %s' % (index, l) for l in msg.splitlines())
29 super(Error, self).__init__(msg, *args, **kwargs)
27 30
28 def SplitUrlRevision(url): 31 def SplitUrlRevision(url):
29 """Splits url and returns a two-tuple: url, rev""" 32 """Splits url and returns a two-tuple: url, rev"""
30 if url.startswith('ssh:'): 33 if url.startswith('ssh:'):
31 # Make sure ssh://user-name@example.com/~/test.git@stable works 34 # Make sure ssh://user-name@example.com/~/test.git@stable works
32 regex = r'(ssh://(?:[-\w]+@)?[-\w:\.]+/[-~\w\./]+)(?:@(.+))?' 35 regex = r'(ssh://(?:[-\w]+@)?[-\w:\.]+/[-~\w\./]+)(?:@(.+))?'
33 components = re.search(regex, url).groups() 36 components = re.search(regex, url).groups()
34 else: 37 else:
35 components = url.split('@', 1) 38 components = url.split('@', 1)
36 if len(components) == 1: 39 if len(components) == 1:
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 871
869 Python on OSX 10.6 raises a NotImplementedError exception. 872 Python on OSX 10.6 raises a NotImplementedError exception.
870 """ 873 """
871 try: 874 try:
872 import multiprocessing 875 import multiprocessing
873 return multiprocessing.cpu_count() 876 return multiprocessing.cpu_count()
874 except: # pylint: disable=W0702 877 except: # pylint: disable=W0702
875 # Mac OS 10.6 only 878 # Mac OS 10.6 only
876 # pylint: disable=E1101 879 # pylint: disable=E1101
877 return int(os.sysconf('SC_NPROCESSORS_ONLN')) 880 return int(os.sysconf('SC_NPROCESSORS_ONLN'))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698