Chromium Code Reviews| Index: fetch.py |
| diff --git a/fetch.py b/fetch.py |
| index 1e5d688f0b177f1d3dcf19c0ba8d4260472d84fa..a975dfca392090667250262e5d6a4add96714388 100755 |
| --- a/fetch.py |
| +++ b/fetch.py |
| @@ -24,6 +24,8 @@ import subprocess |
| import sys |
| import pipes |
| +from distutils import spawn |
| + |
| SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__)) |
| @@ -56,31 +58,40 @@ class Checkout(object): |
| def sync(self): |
| pass |
| + def run(self, tool, cmd_prefix, *cmd, **kwargs): |
| + print 'Running: %s %s' % (tool, |
|
szager1
2013/04/12 03:47:07
Just curious, why print a symbolic name for the co
Dirk Pranke
2013/04/12 03:56:43
Heh. I actually want to be able to cut and paste,
|
| + ' '.join(pipes.quote(x) for x in cmd)) |
| + if self.dryrun: |
| + return 0 |
| + return subprocess.check_call(cmd_prefix + cmd, **kwargs) |
| + |
| class GclientCheckout(Checkout): |
| def run_gclient(self, *cmd, **kwargs): |
| - print 'Running: gclient %s' % ' '.join(pipes.quote(x) for x in cmd) |
| - if not self.dryrun: |
| - return subprocess.check_call( |
| - (sys.executable, os.path.join(SCRIPT_PATH, 'gclient.py')) + cmd, |
| - **kwargs) |
| + return self.run('gclient', |
| + (sys.executable, os.path.join(SCRIPT_PATH, 'gclient.py')), |
| + *cmd, **kwargs) |
| class GitCheckout(Checkout): |
| def run_git(self, *cmd, **kwargs): |
| - print 'Running: git %s' % ' '.join(pipes.quote(x) for x in cmd) |
| - if not self.dryrun: |
| - return subprocess.check_call(('git',) + cmd, **kwargs) |
| + if sys.platform == 'win32' and not spawn.find_executable('git'): |
|
szager1
2013/04/12 03:47:07
Optional, but better organization:
class GitCheck
Dirk Pranke
2013/04/12 03:56:43
I'm not really a fan of class-level statement cont
|
| + git_path = os.path.join(SCRIPT_PATH, 'git-1.8.0_bin', 'bin', 'git.exe') |
| + else: |
| + git_path = 'git' |
| + return self.run('git', (git_path,), *cmd, **kwargs) |
| class SvnCheckout(Checkout): |
| def run_svn(self, *cmd, **kwargs): |
| - print 'Running: svn %s' % ' '.join(pipes.quote(x) for x in cmd) |
| - if not self.dryrun: |
| - return subprocess.check_call(('svn',) + cmd, **kwargs) |
| + if sys.platform == 'win32' and not spawn.find_executable('svn'): |
|
szager1
2013/04/12 03:47:07
Same comment.
Dirk Pranke
2013/04/12 03:56:43
same reply :)
|
| + svn_path = os.path.join(SCRIPT_PATH, 'svn_bin', 'svn.exe') |
| + else: |
| + svn_path = 'svn' |
| + return self.run('svn', (svn_path,), *cmd, **kwargs) |
| class GclientGitCheckout(GclientCheckout, GitCheckout): |