summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Story <mstory@arista.com>2021-10-26 10:56:13 -0400
committerMatt Story <mstory@arista.com>2021-10-27 13:20:35 +0000
commit11b30b91df1f0e03b53da970ec2588e85817bacc (patch)
tree78f5ad7a01151e99fdeb1697b12f6bb52a3a8ba2
parent198838599c5d4eaaa3bd68ff903925eeb4a09da9 (diff)
downloadgit-repo-11b30b91df1f0e03b53da970ec2588e85817bacc.tar.gz
Support more url schemes for getting standalone manifestv2.17.3
urllib.requests.urlopen also supports file, so call it unless the scheme is 'gs'. This adds http, https, and ftp support. Change-Id: I3f215c3ebd8e6dee29ba14c7e79ed99d37287109 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/322095 Reviewed-by: Michael Kelly <mkelly@arista.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Matt Story <mstory@arista.com>
-rw-r--r--fetch.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/fetch.py b/fetch.py
index d79f9479..c954a9c2 100644
--- a/fetch.py
+++ b/fetch.py
@@ -17,6 +17,8 @@
17import subprocess 17import subprocess
18import sys 18import sys
19from urllib.parse import urlparse 19from urllib.parse import urlparse
20from urllib.request import urlopen
21
20 22
21def fetch_file(url, verbose=False): 23def fetch_file(url, verbose=False):
22 """Fetch a file from the specified source using the appropriate protocol. 24 """Fetch a file from the specified source using the appropriate protocol.
@@ -39,7 +41,5 @@ def fetch_file(url, verbose=False):
39 print('fatal: error running "gsutil": %s' % e.stderr, 41 print('fatal: error running "gsutil": %s' % e.stderr,
40 file=sys.stderr) 42 file=sys.stderr)
41 sys.exit(1) 43 sys.exit(1)
42 if scheme == 'file': 44 with urlopen(url) as f:
43 with open(url[len('file://'):], 'rb') as f: 45 return f.read()
44 return f.read()
45 raise ValueError('unsupported url %s' % url)