kopia lustrzana https://github.com/micropython/micropython-lib
upip: Remove wget fallback.
rodzic
cbc423ae41
commit
ab714615c6
68
upip/upip.py
68
upip/upip.py
|
@ -90,52 +90,40 @@ def expandhome(s):
|
||||||
s = s.replace("~/", h + "/")
|
s = s.replace("~/", h + "/")
|
||||||
return s
|
return s
|
||||||
|
|
||||||
try:
|
import ussl
|
||||||
import ussl
|
import usocket
|
||||||
import usocket
|
warn_ussl = True
|
||||||
warn_ussl = True
|
def url_open(url):
|
||||||
def url_open(url):
|
global warn_ussl
|
||||||
global warn_ussl
|
proto, _, host, urlpath = url.split('/', 3)
|
||||||
proto, _, host, urlpath = url.split('/', 3)
|
ai = usocket.getaddrinfo(host, 443)
|
||||||
ai = usocket.getaddrinfo(host, 443)
|
#print("Address infos:", ai)
|
||||||
#print("Address infos:", ai)
|
addr = ai[0][4]
|
||||||
addr = ai[0][4]
|
|
||||||
|
|
||||||
s = usocket.socket(ai[0][0])
|
s = usocket.socket(ai[0][0])
|
||||||
#print("Connect address:", addr)
|
#print("Connect address:", addr)
|
||||||
s.connect(addr)
|
s.connect(addr)
|
||||||
|
|
||||||
if proto == "https:":
|
if proto == "https:":
|
||||||
s = ussl.wrap_socket(s)
|
s = ussl.wrap_socket(s)
|
||||||
if warn_ussl:
|
if warn_ussl:
|
||||||
print("Warning: %s SSL certificate is not validated" % host)
|
print("Warning: %s SSL certificate is not validated" % host)
|
||||||
warn_ussl = False
|
warn_ussl = False
|
||||||
|
|
||||||
# MicroPython rawsocket module supports file interface directly
|
# MicroPython rawsocket module supports file interface directly
|
||||||
s.write("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (urlpath, host))
|
s.write("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (urlpath, host))
|
||||||
|
l = s.readline()
|
||||||
|
protover, status, msg = l.split(None, 2)
|
||||||
|
if status != b"200":
|
||||||
|
raise OSError()
|
||||||
|
while 1:
|
||||||
l = s.readline()
|
l = s.readline()
|
||||||
protover, status, msg = l.split(None, 2)
|
if not l:
|
||||||
if status != b"200":
|
|
||||||
raise OSError()
|
raise OSError()
|
||||||
while 1:
|
if l == b'\r\n':
|
||||||
l = s.readline()
|
break
|
||||||
if not l:
|
|
||||||
raise OSError()
|
|
||||||
if l == b'\r\n':
|
|
||||||
break
|
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
except ImportError:
|
|
||||||
|
|
||||||
def download(url, local_name):
|
|
||||||
if debug:
|
|
||||||
print("wget -q %s -O %s" % (url, local_name))
|
|
||||||
rc = os.system("wget -q %s -O %s" % (url, local_name))
|
|
||||||
if local_name not in cleanup_files:
|
|
||||||
cleanup_files.append(local_name)
|
|
||||||
if rc == 8 * 256:
|
|
||||||
raise NotFoundError
|
|
||||||
|
|
||||||
|
|
||||||
def get_pkg_metadata(name):
|
def get_pkg_metadata(name):
|
||||||
|
|
Ładowanie…
Reference in New Issue