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

Side by Side Diff: gclient_utils.py

Issue 10034011: Check the existence and executability of scm commands (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Created 8 years, 8 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 | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | 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 errno 7 import errno
8 import logging 8 import logging
9 import os 9 import os
10 import Queue 10 import Queue
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 os.makedirs(tree) 186 os.makedirs(tree)
187 except OSError, e: 187 except OSError, e:
188 # 17 POSIX, 183 Windows 188 # 17 POSIX, 183 Windows
189 if e.errno not in (17, 183): 189 if e.errno not in (17, 183):
190 raise 190 raise
191 if count > 40: 191 if count > 40:
192 # Give up. 192 # Give up.
193 raise 193 raise
194 194
195 195
196 def FindCommandExecutable(cmd):
197 """Finds the specified |cmd| in $PATH and returns its path. Returns None
198 if it's not found."""
199 for path in os.environ['PATH'].split(os.pathsep):
200 full_path = os.path.join(path, cmd)
201 if os.path.isfile(full_path) and os.access(full_path, os.X_OK):
202 return full_path
203 return None
204
205
196 def CheckCallAndFilterAndHeader(args, always=False, **kwargs): 206 def CheckCallAndFilterAndHeader(args, always=False, **kwargs):
197 """Adds 'header' support to CheckCallAndFilter. 207 """Adds 'header' support to CheckCallAndFilter.
198 208
199 If |always| is True, a message indicating what is being done 209 If |always| is True, a message indicating what is being done
200 is printed to stdout all the time even if not output is generated. Otherwise 210 is printed to stdout all the time even if not output is generated. Otherwise
201 the message header is printed only if the call generated any ouput. 211 the message header is printed only if the call generated any ouput.
202 """ 212 """
203 stdout = kwargs.get('stdout', None) or sys.stdout 213 stdout = kwargs.get('stdout', None) or sys.stdout
204 if always: 214 if always:
205 stdout.write('\n________ running \'%s\' in \'%s\'\n' 215 stdout.write('\n________ running \'%s\' in \'%s\'\n'
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 keyvals = dict([x.strip() for x in l.split(':', 1)] for l in lines if l) 776 keyvals = dict([x.strip() for x in l.split(':', 1)] for l in lines if l)
767 except ValueError: 777 except ValueError:
768 raise Error( 778 raise Error(
769 'Failed to process settings, please fix. Content:\n\n%s' % content) 779 'Failed to process settings, please fix. Content:\n\n%s' % content)
770 def fix_url(key): 780 def fix_url(key):
771 if keyvals.get(key): 781 if keyvals.get(key):
772 keyvals[key] = UpgradeToHttps(keyvals[key]) 782 keyvals[key] = UpgradeToHttps(keyvals[key])
773 fix_url('CODE_REVIEW_SERVER') 783 fix_url('CODE_REVIEW_SERVER')
774 fix_url('VIEW_VC') 784 fix_url('VIEW_VC')
775 return keyvals 785 return keyvals
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698