Chromium Code Reviews| Index: gclient_scm.py |
| =================================================================== |
| --- gclient_scm.py (revision 131926) |
| +++ gclient_scm.py (working copy) |
| @@ -76,6 +76,21 @@ |
| return None |
| +def CheckCommandExecutable(cmd): |
|
M-A Ruel
2012/04/12 17:37:38
This belongs to gclient_utils.
Jun Mukai
2012/04/13 06:00:53
Done.
|
| + """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(os.pathsep) |
|
M-A Ruel
2012/04/12 17:37:38
os.environ['PATH'].split(os.pathsep)
You can safe
Jun Mukai
2012/04/13 06:00:53
Done.
|
| + 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) |
|
M-A Ruel
2012/04/12 17:37:38
Why raise? FWIU, 'which' would move on. You should
Jun Mukai
2012/04/13 06:00:53
Done.
|
| + 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) |
|
M-A Ruel
2012/04/12 17:37:38
I prefer this function to return the path of the c
Jun Mukai
2012/04/13 06:00:53
Done.
The reason for raise was that there could be
|
| + |
| + |
| 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) |