diff options
author | Matt Story <mstory@arista.com> | 2021-10-26 10:56:13 -0400 |
---|---|---|
committer | Matt Story <mstory@arista.com> | 2021-10-27 13:20:35 +0000 |
commit | 11b30b91df1f0e03b53da970ec2588e85817bacc (patch) | |
tree | 78f5ad7a01151e99fdeb1697b12f6bb52a3a8ba2 | |
parent | 198838599c5d4eaaa3bd68ff903925eeb4a09da9 (diff) | |
download | git-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.py | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -17,6 +17,8 @@ | |||
17 | import subprocess | 17 | import subprocess |
18 | import sys | 18 | import sys |
19 | from urllib.parse import urlparse | 19 | from urllib.parse import urlparse |
20 | from urllib.request import urlopen | ||
21 | |||
20 | 22 | ||
21 | def fetch_file(url, verbose=False): | 23 | def 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) | ||