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

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: Fix tests 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 | tests/gsutil_test.py » ('j') | 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..f2f2b72acca2c9e38f160e1f90cb9dcf3805b6ad 100755
--- a/gsutil.py
+++ b/gsutil.py
@@ -27,31 +27,10 @@ DEFAULT_FALLBACK_GSUTIL = os.path.join(
THIS_DIR, 'third_party', 'gsutil', 'gsutil')
-class SubprocessError(Exception):
- def __init__(self, message=None, code=0):
- super(SubprocessError, self).__init__(message)
- self.code = code
-
-
class InvalidGsutilError(Exception):
pass
-def call(args, verbose=True, **kwargs):
- kwargs['stdout'] = subprocess.PIPE
- kwargs['stderr'] = subprocess.STDOUT
- 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)
-
-
def download_gsutil(version, target_dir):
"""Downloads gsutil into the target_dir."""
filename = 'gsutil_%s.zip' % version
@@ -90,12 +69,9 @@ 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 subprocess.call(
+ [sys.executable, gsutil_bin, 'version'],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT) == 0
def ensure_gsutil(version, target):
bin_dir = os.path.join(target, 'gsutil_%s' % version)
@@ -127,11 +103,7 @@ def run_gsutil(force_version, fallback, target, args):
else:
gsutil_bin = fallback
cmd = [sys.executable, gsutil_bin] + args
- try:
- call(cmd)
- except SubprocessError as e:
- return e.code
- return 0
+ return subprocess.call(cmd)
def parse_args():
« no previous file with comments | « no previous file | tests/gsutil_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698