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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 if not editor: | 799 if not editor: |
800 if sys.platform.startswith('win'): | 800 if sys.platform.startswith('win'): |
801 editor = 'notepad' | 801 editor = 'notepad' |
802 else: | 802 else: |
803 editor = 'vim' | 803 editor = 'vim' |
804 return editor | 804 return editor |
805 | 805 |
806 | 806 |
807 def RunEditor(content, git, git_editor=None): | 807 def RunEditor(content, git, git_editor=None): |
808 """Opens up the default editor in the system to get the CL description.""" | 808 """Opens up the default editor in the system to get the CL description.""" |
809 file_handle, filename = tempfile.mkstemp(text=True) | 809 file_handle, filename = tempfile.mkstemp(text=True, prefix='cl_description') |
810 # Make sure CRLF is handled properly by requiring none. | 810 # Make sure CRLF is handled properly by requiring none. |
811 if '\r' in content: | 811 if '\r' in content: |
812 print >> sys.stderr, ( | 812 print >> sys.stderr, ( |
813 '!! Please remove \\r from your change description !!') | 813 '!! Please remove \\r from your change description !!') |
814 fileobj = os.fdopen(file_handle, 'w') | 814 fileobj = os.fdopen(file_handle, 'w') |
815 # Still remove \r if present. | 815 # Still remove \r if present. |
816 fileobj.write(re.sub('\r?\n', '\n', content)) | 816 fileobj.write(re.sub('\r?\n', '\n', content)) |
817 fileobj.close() | 817 fileobj.close() |
818 | 818 |
819 try: | 819 try: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 | 877 |
878 Python on OSX 10.6 raises a NotImplementedError exception. | 878 Python on OSX 10.6 raises a NotImplementedError exception. |
879 """ | 879 """ |
880 try: | 880 try: |
881 import multiprocessing | 881 import multiprocessing |
882 return multiprocessing.cpu_count() | 882 return multiprocessing.cpu_count() |
883 except: # pylint: disable=W0702 | 883 except: # pylint: disable=W0702 |
884 # Mac OS 10.6 only | 884 # Mac OS 10.6 only |
885 # pylint: disable=E1101 | 885 # pylint: disable=E1101 |
886 return int(os.sysconf('SC_NPROCESSORS_ONLN')) | 886 return int(os.sysconf('SC_NPROCESSORS_ONLN')) |
OLD | NEW |