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

Unified Diff: download_from_google_storage.py

Issue 240203005: Implement git-drover. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: address feedback Created 6 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 | git-drover » ('j') | git_drover.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: download_from_google_storage.py
diff --git a/download_from_google_storage.py b/download_from_google_storage.py
index 8370515e6a15879c3ddf5c1e8693efeb595a8ccd..6d62d8774416ae6ea6caef2322042fbeb766955e 100755
--- a/download_from_google_storage.py
+++ b/download_from_google_storage.py
@@ -66,7 +66,7 @@ class Gsutil(object):
def get_sub_env(self):
env = os.environ.copy()
if self.boto_path == os.devnull:
- env['AWS_CREDENTIAL_FILE'] = ''
+ env.pop('AWS_CREDENTIAL_FILE', None)
env['BOTO_CONFIG'] = ''
elif self.boto_path:
env['AWS_CREDENTIAL_FILE'] = self.boto_path
@@ -86,17 +86,35 @@ class Gsutil(object):
cmd.extend(args)
return subprocess2.call(cmd, env=self.get_sub_env(), timeout=self.timeout)
- def check_call(self, *args):
+ def check_call(self, *args, **kwargs):
+ def tee(stream, buf):
+ def _inner(char):
+ stream.write(char)
+ buf.append(char)
+ return _inner
+
cmd = [sys.executable, self.path]
if self.bypass_prodaccess:
cmd.append('--bypass_prodaccess')
cmd.extend(args)
- ((out, err), code) = subprocess2.communicate(
- cmd,
- stdout=subprocess2.PIPE,
- stderr=subprocess2.PIPE,
- env=self.get_sub_env(),
- timeout=self.timeout)
+
+ out = []
+ err = []
+
+ proc = subprocess2.Popen(cmd, env=self.get_sub_env(),
+ stdout=subprocess2.PIPE,
+ stderr=subprocess2.PIPE)
+ if kwargs.get('verbose'):
+ proc.stdout_cb = tee(sys.stdout, out)
+ proc.stderr_cb = tee(sys.stderr, err)
+ else:
+ proc.stdout_cb = out.append
+ proc.stderr_cb = err.append
+ proc.communicate(timeout=self.timeout)
+ code = proc.returncode
+
+ out = ''.join(out)
+ err = ''.join(err)
# Parse output.
status_code_match = re.search('status=([0-9]+)', err)
« no previous file with comments | « no previous file | git-drover » ('j') | git_drover.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698