| 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)
|
|
|