diff options
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/recipetool/create_go.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/lib/recipetool/create_go.py b/scripts/lib/recipetool/create_go.py index c560831442..0fb7115e26 100644 --- a/scripts/lib/recipetool/create_go.py +++ b/scripts/lib/recipetool/create_go.py | |||
@@ -16,7 +16,7 @@ from html.parser import HTMLParser | |||
16 | from recipetool.create import RecipeHandler, handle_license_vars | 16 | from recipetool.create import RecipeHandler, handle_license_vars |
17 | from recipetool.create import guess_license, tidy_licenses, fixup_license | 17 | from recipetool.create import guess_license, tidy_licenses, fixup_license |
18 | from recipetool.create import determine_from_url | 18 | from recipetool.create import determine_from_url |
19 | from urllib.error import URLError | 19 | from urllib.error import URLError, HTTPError |
20 | 20 | ||
21 | import bb.utils | 21 | import bb.utils |
22 | import json | 22 | import json |
@@ -251,15 +251,18 @@ class GoRecipeHandler(RecipeHandler): | |||
251 | req = urllib.request.Request(url) | 251 | req = urllib.request.Request(url) |
252 | 252 | ||
253 | try: | 253 | try: |
254 | resp = urllib.request.urlopen(req) | 254 | body = urllib.request.urlopen(req).read() |
255 | 255 | except HTTPError as http_err: | |
256 | logger.warning( | ||
257 | "Unclean status when fetching page from [%s]: %s", url, str(http_err)) | ||
258 | body = http_err.fp.read() | ||
256 | except URLError as url_err: | 259 | except URLError as url_err: |
257 | logger.warning( | 260 | logger.warning( |
258 | "Failed to fetch page from [%s]: %s", url, str(url_err)) | 261 | "Failed to fetch page from [%s]: %s", url, str(url_err)) |
259 | return None | 262 | return None |
260 | 263 | ||
261 | parser = GoImportHTMLParser() | 264 | parser = GoImportHTMLParser() |
262 | parser.feed(resp.read().decode('utf-8')) | 265 | parser.feed(body.decode('utf-8')) |
263 | parser.close() | 266 | parser.close() |
264 | 267 | ||
265 | return GoImport(parser.import_prefix, parser.vcs, parser.repourl, None) | 268 | return GoImport(parser.import_prefix, parser.vcs, parser.repourl, None) |