diff options
author | Ross Burton <ross.burton@arm.com> | 2023-02-14 16:07:51 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-02-17 18:02:04 +0000 |
commit | 77f91746dc86656dd960d910698c51a0559d1837 (patch) | |
tree | 48e47ca280a746abc235de4cc88e6d891e7e38cf /bitbake/lib/bb | |
parent | d976eb3d5257174900eebedc9495052bb3936ce7 (diff) | |
download | poky-77f91746dc86656dd960d910698c51a0559d1837.tar.gz |
bitbake: fetch2/wget: clean up netrc usage
Assigning a return value which is potentially None to a tuple and
catching TypeError is pretty ugly. Rewrite the code to explicitly check
the value for clarity.
(Bitbake rev: f4ebb27616ac2df27c29a6052b1526a4c48db607)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/fetch2/wget.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py index 696e918030..6d365729e0 100644 --- a/bitbake/lib/bb/fetch2/wget.py +++ b/bitbake/lib/bb/fetch2/wget.py | |||
@@ -361,10 +361,11 @@ class Wget(FetchMethod): | |||
361 | 361 | ||
362 | try: | 362 | try: |
363 | import netrc | 363 | import netrc |
364 | n = netrc.netrc() | 364 | auth_data = netrc.netrc().authenticators(urllib.parse.urlparse(uri).hostname) |
365 | login, unused, password = n.authenticators(urllib.parse.urlparse(uri).hostname) | 365 | if auth_data: |
366 | add_basic_auth("%s:%s" % (login, password), r) | 366 | login, _, password = auth_data |
367 | except (TypeError, ImportError, IOError, netrc.NetrcParseError): | 367 | add_basic_auth("%s:%s" % (login, password), r) |
368 | except (FileNotFoundError, netrc.NetrcParseError): | ||
368 | pass | 369 | pass |
369 | 370 | ||
370 | with opener.open(r, timeout=30) as response: | 371 | with opener.open(r, timeout=30) as response: |