diff --git a/fetch.py b/fetch.py index 91d40cda..d79f9479 100644 --- a/fetch.py +++ b/fetch.py @@ -18,7 +18,7 @@ import subprocess import sys from urllib.parse import urlparse -def fetch_file(url): +def fetch_file(url, verbose=False): """Fetch a file from the specified source using the appropriate protocol. Returns: @@ -29,10 +29,14 @@ def fetch_file(url): cmd = ['gsutil', 'cat', url] try: result = subprocess.run( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + check=True) + if result.stderr and verbose: + print('warning: non-fatal error running "gsutil": %s' % result.stderr, + file=sys.stderr) return result.stdout except subprocess.CalledProcessError as e: - print('fatal: error running "gsutil": %s' % e.output, + print('fatal: error running "gsutil": %s' % e.stderr, file=sys.stderr) sys.exit(1) if scheme == 'file': diff --git a/subcmds/init.py b/subcmds/init.py index 853cbe68..a3f3241a 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -298,7 +298,7 @@ to update the working directory files. if standalone_manifest: if is_new: manifest_name = 'default.xml' - manifest_data = fetch.fetch_file(opt.manifest_url) + manifest_data = fetch.fetch_file(opt.manifest_url, verbose=opt.verbose) dest = os.path.join(m.worktree, manifest_name) os.makedirs(os.path.dirname(dest), exist_ok=True) with open(dest, 'wb') as f: