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

Unified Diff: gsutil.py

Issue 870093003: Hook sys.stdio directly to the gsutil subprocess for the gsutil call (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Print to stderr Created 5 years, 11 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: gsutil.py
diff --git a/gsutil.py b/gsutil.py
index 6578d7844171202eb787bf1414c4a371e15a75a0..b873f0873085ea01d90a2461caa63f00ad297e6c 100755
--- a/gsutil.py
+++ b/gsutil.py
@@ -37,19 +37,12 @@ class InvalidGsutilError(Exception):
pass
-def call(args, verbose=True, **kwargs):
- kwargs['stdout'] = subprocess.PIPE
- kwargs['stderr'] = subprocess.STDOUT
+def call(args, **kwargs):
scottmg 2015/01/23 21:09:41 I think this is just subprocess.call() now?
hinoka 2015/01/23 21:56:25 You're right. Done. I'm keeping the alias, becau
+ kwargs['stdout'] = sys.stdout
+ kwargs['stderr'] = sys.stderr
+ kwargs['stdin'] = sys.stdin
proc = subprocess.Popen(args, **kwargs)
- out = []
- for line in proc.stdout:
- out.append(line)
- if verbose:
- sys.stdout.write(line)
- code = proc.wait()
- if code:
- raise SubprocessError('%s failed with %s' % (args, code), code)
- return ''.join(out)
+ return proc.wait()
def download_gsutil(version, target_dir):
@@ -79,6 +72,7 @@ def download_gsutil(version, target_dir):
# Do the download.
url = '%s%s' % (GSUTIL_URL, filename)
u = urllib2.urlopen(url)
+ print >> sys.stderr, 'Downloading gsutil from %s...' % url
with open(target_filename, 'wb') as f:
while True:
buf = u.read(4096)
@@ -90,11 +84,7 @@ def download_gsutil(version, target_dir):
def check_gsutil(gsutil_bin):
"""Run gsutil version and make sure it runs."""
- try:
- call([sys.executable, gsutil_bin, 'version'], verbose=False)
- return True
- except SubprocessError:
- return False
+ return call([sys.executable, gsutil_bin, 'version']) == 0
def ensure_gsutil(version, target):
« 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