mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00
recipetool: Handle unclean response in go resolver
It appears that some go modules repond with a 404 error when trying to resolve them dynamically. The response body may still contain the go-import meta tag. An example for such behaviour is gonum.org/v1/gonum. (From OE-Core rev: 8f2e14ab6562a9a68819a960c66a258ea9dbe246) Signed-off-by: Sven Schwermer <sven.schwermer@disruptive-technologies.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
0d6a71d492
commit
e4c3483ecf
|
@ -16,7 +16,7 @@ from html.parser import HTMLParser
|
|||
from recipetool.create import RecipeHandler, handle_license_vars
|
||||
from recipetool.create import guess_license, tidy_licenses, fixup_license
|
||||
from recipetool.create import determine_from_url
|
||||
from urllib.error import URLError
|
||||
from urllib.error import URLError, HTTPError
|
||||
|
||||
import bb.utils
|
||||
import json
|
||||
|
@ -251,15 +251,18 @@ class GoRecipeHandler(RecipeHandler):
|
|||
req = urllib.request.Request(url)
|
||||
|
||||
try:
|
||||
resp = urllib.request.urlopen(req)
|
||||
|
||||
body = urllib.request.urlopen(req).read()
|
||||
except HTTPError as http_err:
|
||||
logger.warning(
|
||||
"Unclean status when fetching page from [%s]: %s", url, str(http_err))
|
||||
body = http_err.fp.read()
|
||||
except URLError as url_err:
|
||||
logger.warning(
|
||||
"Failed to fetch page from [%s]: %s", url, str(url_err))
|
||||
return None
|
||||
|
||||
parser = GoImportHTMLParser()
|
||||
parser.feed(resp.read().decode('utf-8'))
|
||||
parser.feed(body.decode('utf-8'))
|
||||
parser.close()
|
||||
|
||||
return GoImport(parser.import_prefix, parser.vcs, parser.repourl, None)
|
||||
|
|
Loading…
Reference in New Issue
Block a user