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

Side by Side Diff: gclient_utils.py

Issue 19498004: Add a prefix to temporary file to enter CL description. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 7 years, 5 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 pipes 10 import pipes
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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'))
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