Chromium Code Reviews| Index: download_from_google_storage.py |
| diff --git a/download_from_google_storage.py b/download_from_google_storage.py |
| index 766a2b85500e7644069b1781f92f3576cf135584..42c86ca77ef0837e05ae2876554ee65d71da4148 100755 |
| --- a/download_from_google_storage.py |
| +++ b/download_from_google_storage.py |
| @@ -36,12 +36,13 @@ class InvalidFileError(IOError): |
| class Gsutil(object): |
| """Call gsutil with some predefined settings. This is a convenience object, |
| and is also immutable.""" |
| - def __init__(self, path, boto_path, timeout=None): |
| + def __init__(self, path, boto_path, timeout=None, bypass_prodaccess=False): |
| if not os.path.exists(path): |
| raise FileNotFoundError('GSUtil not found in %s' % path) |
| self.path = path |
| self.timeout = timeout |
| self.boto_path = boto_path |
| + self.bypass_prodaccess = False |
|
Vadim Sh.
2013/12/03 01:33:41
Did you mean self.bypass_prodaccess = bypass_proda
Ryan Tseng
2013/12/03 22:57:11
Oops, yes
|
| def get_sub_env(self): |
| env = os.environ.copy() |
| @@ -60,11 +61,15 @@ class Gsutil(object): |
| return env |
| def call(self, *args): |
| + if self.bypass_prodaccess: |
| + args.insert(0, '--bypass_prodaccess') |
|
Vadim Sh.
2013/12/03 01:33:41
|args| is a tuple here. You can't insert stuff int
Ryan Tseng
2013/12/03 22:57:11
fixed
|
| return subprocess2.call((sys.executable, self.path) + args, |
| env=self.get_sub_env(), |
| timeout=self.timeout) |
| def check_call(self, *args): |
| + if self.bypass_prodaccess: |
| + args.insert(0, '--bypass_prodaccess') |
| ((out, err), code) = subprocess2.communicate( |
| (sys.executable, self.path) + args, |
| stdout=subprocess2.PIPE, |
| @@ -329,12 +334,16 @@ def main(args): |
| # Make sure we can find a working instance of gsutil. |
| if os.path.exists(GSUTIL_DEFAULT_PATH): |
| - gsutil = Gsutil(GSUTIL_DEFAULT_PATH, boto_path=options.boto) |
| + gsutil = Gsutil(GSUTIL_DEFAULT_PATH, |
| + boto_path=options.boto, |
| + bypass_prodaccess=options.no_auth) |
| else: |
| gsutil = None |
| for path in os.environ["PATH"].split(os.pathsep): |
| if os.path.exists(path) and 'gsutil' in os.listdir(path): |
| - gsutil = Gsutil(os.path.join(path, 'gsutil'), boto_path=options.boto) |
| + gsutil = Gsutil(os.path.join(path, 'gsutil'), |
| + boto_path=options.boto, |
| + bypass_prodaccess=False) |
|
Vadim Sh.
2013/12/03 01:33:41
Why not use options.no_auth here as well? Is it be
Ryan Tseng
2013/12/03 22:57:11
Actually this business with finding an existing ve
|
| if not gsutil: |
| parser.error('gsutil not found in %s, bad depot_tools checkout?' % |
| GSUTIL_DEFAULT_PATH) |