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 |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 except KeyboardInterrupt: | 477 except KeyboardInterrupt: |
478 print >> sys.stderr, 'Failed while running "%s"' % ' '.join(args) | 478 print >> sys.stderr, 'Failed while running "%s"' % ' '.join(args) |
479 raise | 479 raise |
480 | 480 |
481 if rv == 0: | 481 if rv == 0: |
482 return 0 | 482 return 0 |
483 if not retry: | 483 if not retry: |
484 break | 484 break |
485 print ("WARNING: subprocess '%s' in %s failed; will retry after a short " | 485 print ("WARNING: subprocess '%s' in %s failed; will retry after a short " |
486 'nap...' % (' '.join('"%s"' % x for x in args), run_cwd)) | 486 'nap...' % (' '.join('"%s"' % x for x in args), run_cwd)) |
487 sys.sleep(sleep_interval) | 487 time.sleep(sleep_interval) |
488 sleep_interval *= 2 | 488 sleep_interval *= 2 |
489 raise subprocess2.CalledProcessError( | 489 raise subprocess2.CalledProcessError( |
490 rv, args, kwargs.get('cwd', None), None, None) | 490 rv, args, kwargs.get('cwd', None), None, None) |
491 | 491 |
492 | 492 |
493 def FindGclientRoot(from_dir, filename='.gclient'): | 493 def FindGclientRoot(from_dir, filename='.gclient'): |
494 """Tries to find the gclient root.""" | 494 """Tries to find the gclient root.""" |
495 real_from_dir = os.path.realpath(from_dir) | 495 real_from_dir = os.path.realpath(from_dir) |
496 path = real_from_dir | 496 path = real_from_dir |
497 while not os.path.exists(os.path.join(path, filename)): | 497 while not os.path.exists(os.path.join(path, filename)): |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 | 894 |
895 Python on OSX 10.6 raises a NotImplementedError exception. | 895 Python on OSX 10.6 raises a NotImplementedError exception. |
896 """ | 896 """ |
897 try: | 897 try: |
898 import multiprocessing | 898 import multiprocessing |
899 return multiprocessing.cpu_count() | 899 return multiprocessing.cpu_count() |
900 except: # pylint: disable=W0702 | 900 except: # pylint: disable=W0702 |
901 # Mac OS 10.6 only | 901 # Mac OS 10.6 only |
902 # pylint: disable=E1101 | 902 # pylint: disable=E1101 |
903 return int(os.sysconf('SC_NPROCESSORS_ONLN')) | 903 return int(os.sysconf('SC_NPROCESSORS_ONLN')) |
OLD | NEW |