mirror of
https://github.com/J3rome/py-requirements-guesser.git
synced 2024-11-22 09:55:18 +01:00
* Fix HTTP error handling
This commit is contained in:
parent
f94c4a2d7c
commit
4253e368fc
9
main.py
9
main.py
@ -38,14 +38,13 @@ def get_pypi_history(package_name, ignore_release_candidat=True):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
resp = urlopen(f"https://pypi.org/pypi/{package_name}/json")
|
resp = urlopen(f"https://pypi.org/pypi/{package_name}/json")
|
||||||
except:
|
except Exception as e:
|
||||||
|
if hasattr(e, 'getcode') and e.getcode() == 404:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
print("[ERROR] Internet access is required to fetch package history from Pypi")
|
print("[ERROR] Internet access is required to fetch package history from Pypi")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
if resp.code != 200:
|
|
||||||
print(f"[INFO] Couldn't find package '{package_name} on Pypi. Ignoring")
|
|
||||||
return None
|
|
||||||
|
|
||||||
resp = json.loads(resp.read())
|
resp = json.loads(resp.read())
|
||||||
|
|
||||||
versions = []
|
versions = []
|
||||||
|
Loading…
Reference in New Issue
Block a user