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

Unified Diff: gclient_scm.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
===================================================================
--- gclient_scm.py (revision 131736)
+++ gclient_scm.py (working copy)
@@ -76,6 +76,21 @@
return None
+def CheckCommandExecutable(cmd):
+ """Find the specified |cmd| in $PATH and checks if it's executable.
+ Raise an exception if fails. Otherwise do nothing."""
+ paths = os.getenv('PATH').split(':')
satorux1 2012/04/11 17:09:14 this fails if PATH is not set. os.getenv('PATH', '
Jun Mukai 2012/04/12 09:51:14 Done. Also introduced os.pathsep instead of ':',
+ for path in paths:
+ full_path = os.path.join(path, cmd)
+ if os.path.exists(full_path):
+ if not os.path.isfile(full_path):
+ raise gclient_utils.Error('%s is not a file.' % full_path)
+ if not os.access(full_path, os.X_OK):
+ raise gclient_utils.Error('%s is not executable.' % full_path)
+ return
+ raise gclient_utils.Error('%s command is not found.' % cmd)
+
+
def CreateSCM(url, root_dir=None, relpath=None):
SCM_MAP = {
'svn' : SVNWrapper,
@@ -85,6 +100,7 @@
scm_name = GetScmName(url)
if not scm_name in SCM_MAP:
raise gclient_utils.Error('No SCM found for url %s' % url)
+ CheckCommandExecutable(scm_name)
return SCM_MAP[scm_name](url, root_dir, relpath)
« 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