tools/upip: Update to 1.1.5. Better and more user-friendly error handling.
This commit is contained in:
parent
e08395a35c
commit
aac2db9aaf
@ -105,7 +105,10 @@ warn_ussl = True
|
||||
def url_open(url):
|
||||
global warn_ussl
|
||||
proto, _, host, urlpath = url.split('/', 3)
|
||||
try:
|
||||
ai = usocket.getaddrinfo(host, 443)
|
||||
except OSError as e:
|
||||
fatal("Unable to resolve %s (no Internet?)" % host, e)
|
||||
#print("Address infos:", ai)
|
||||
addr = ai[0][4]
|
||||
|
||||
@ -124,13 +127,16 @@ def url_open(url):
|
||||
l = s.readline()
|
||||
protover, status, msg = l.split(None, 2)
|
||||
if status != b"200":
|
||||
s.close()
|
||||
exc = ValueError(status)
|
||||
if status == b"404":
|
||||
print("Package not found")
|
||||
raise ValueError(status)
|
||||
fatal("Package not found", exc)
|
||||
fatal("Unexpected error querying for package", exc)
|
||||
while 1:
|
||||
l = s.readline()
|
||||
if not l:
|
||||
raise ValueError("Unexpected EOF")
|
||||
s.close()
|
||||
fatal("Unexpected EOF in HTTP headers", ValueError())
|
||||
if l == b'\r\n':
|
||||
break
|
||||
|
||||
@ -144,8 +150,10 @@ def get_pkg_metadata(name):
|
||||
return json.loads(s)
|
||||
|
||||
|
||||
def fatal(msg):
|
||||
print(msg)
|
||||
def fatal(msg, exc=None):
|
||||
print("Error:", msg)
|
||||
if exc and debug:
|
||||
raise exc
|
||||
sys.exit(1)
|
||||
|
||||
def install_pkg(pkg_spec, install_path):
|
||||
|
Loading…
Reference in New Issue
Block a user