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 errno | 8 import errno |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 keyvals = dict([x.strip() for x in l.split(':', 1)] for l in lines if l) | 762 keyvals = dict([x.strip() for x in l.split(':', 1)] for l in lines if l) |
763 except ValueError: | 763 except ValueError: |
764 raise Error( | 764 raise Error( |
765 'Failed to process settings, please fix. Content:\n\n%s' % content) | 765 'Failed to process settings, please fix. Content:\n\n%s' % content) |
766 def fix_url(key): | 766 def fix_url(key): |
767 if keyvals.get(key): | 767 if keyvals.get(key): |
768 keyvals[key] = UpgradeToHttps(keyvals[key]) | 768 keyvals[key] = UpgradeToHttps(keyvals[key]) |
769 fix_url('CODE_REVIEW_SERVER') | 769 fix_url('CODE_REVIEW_SERVER') |
770 fix_url('VIEW_VC') | 770 fix_url('VIEW_VC') |
771 return keyvals | 771 return keyvals |
| 772 |
| 773 |
| 774 def NumLocalCpus(): |
| 775 """Returns the number of processors. |
| 776 |
| 777 Python on OSX 10.6 raises a NotImplementedError exception. |
| 778 """ |
| 779 try: |
| 780 import multiprocessing |
| 781 return multiprocessing.cpu_count() |
| 782 except: # pylint: disable=W0702 |
| 783 # Mac OS 10.6 only |
| 784 # pylint: disable=E1101 |
| 785 return int(os.sysconf('SC_NPROCESSORS_ONLN')) |
OLD | NEW |