mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 09:00:23 +08:00
tools/upip: Upgrade upip to 1.2.4.
Uses new pypi.org URL, and now creates a socket with the address parameters returned by getaddrinfo().
This commit is contained in:
parent
b5ee3b2f21
commit
f7be5f9bfa
@ -17,7 +17,7 @@ fi
|
|||||||
|
|
||||||
# Remove any stale old version
|
# Remove any stale old version
|
||||||
rm -rf micropython-upip-*
|
rm -rf micropython-upip-*
|
||||||
wget -nd -r -l1 https://pypi.python.org/pypi/micropython-upip/ --accept-regex ".*pypi.python.org/packages/source/.*.gz" --reject=html
|
wget -nd -rH -l1 -D files.pythonhosted.org https://pypi.org/project/micropython-upip/ --reject=html
|
||||||
|
|
||||||
tar xfz micropython-upip-*.tar.gz
|
tar xfz micropython-upip-*.tar.gz
|
||||||
tmpd="$PWD"
|
tmpd="$PWD"
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
#
|
||||||
|
# upip - Package manager for MicroPython
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015-2018 Paul Sokolovsky
|
||||||
|
#
|
||||||
|
# Licensed under the MIT license.
|
||||||
|
#
|
||||||
import sys
|
import sys
|
||||||
import gc
|
import gc
|
||||||
import uos as os
|
import uos as os
|
||||||
@ -110,16 +117,16 @@ def url_open(url):
|
|||||||
|
|
||||||
proto, _, host, urlpath = url.split('/', 3)
|
proto, _, host, urlpath = url.split('/', 3)
|
||||||
try:
|
try:
|
||||||
ai = usocket.getaddrinfo(host, 443)
|
ai = usocket.getaddrinfo(host, 443, 0, usocket.SOCK_STREAM)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
fatal("Unable to resolve %s (no Internet?)" % host, e)
|
fatal("Unable to resolve %s (no Internet?)" % host, e)
|
||||||
#print("Address infos:", ai)
|
#print("Address infos:", ai)
|
||||||
addr = ai[0][4]
|
ai = ai[0]
|
||||||
|
|
||||||
s = usocket.socket(ai[0][0])
|
s = usocket.socket(ai[0], ai[1], ai[2])
|
||||||
try:
|
try:
|
||||||
#print("Connect address:", addr)
|
#print("Connect address:", addr)
|
||||||
s.connect(addr)
|
s.connect(ai[-1])
|
||||||
|
|
||||||
if proto == "https:":
|
if proto == "https:":
|
||||||
s = ussl.wrap_socket(s, server_hostname=host)
|
s = ussl.wrap_socket(s, server_hostname=host)
|
||||||
@ -149,7 +156,7 @@ def url_open(url):
|
|||||||
|
|
||||||
|
|
||||||
def get_pkg_metadata(name):
|
def get_pkg_metadata(name):
|
||||||
f = url_open("https://pypi.python.org/pypi/%s/json" % name)
|
f = url_open("https://pypi.org/pypi/%s/json" % name)
|
||||||
try:
|
try:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user