Skip to content

Commit ab71461

Browse files
committed
upip: Remove wget fallback.
1 parent cbc423a commit ab71461

File tree

1 file changed

+32
-44
lines changed

1 file changed

+32
-44
lines changed

upip/upip.py

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -90,52 +90,40 @@ def expandhome(s):
9090
s = s.replace("~/", h + "/")
9191
return s
9292

93-
try:
94-
import ussl
95-
import usocket
96-
warn_ussl = True
97-
def url_open(url):
98-
global warn_ussl
99-
proto, _, host, urlpath = url.split('/', 3)
100-
ai = usocket.getaddrinfo(host, 443)
101-
#print("Address infos:", ai)
102-
addr = ai[0][4]
103-
104-
s = usocket.socket(ai[0][0])
105-
#print("Connect address:", addr)
106-
s.connect(addr)
107-
108-
if proto == "https:":
109-
s = ussl.wrap_socket(s)
110-
if warn_ussl:
111-
print("Warning: %s SSL certificate is not validated" % host)
112-
warn_ussl = False
113-
114-
# MicroPython rawsocket module supports file interface directly
115-
s.write("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (urlpath, host))
93+
import ussl
94+
import usocket
95+
warn_ussl = True
96+
def url_open(url):
97+
global warn_ussl
98+
proto, _, host, urlpath = url.split('/', 3)
99+
ai = usocket.getaddrinfo(host, 443)
100+
#print("Address infos:", ai)
101+
addr = ai[0][4]
102+
103+
s = usocket.socket(ai[0][0])
104+
#print("Connect address:", addr)
105+
s.connect(addr)
106+
107+
if proto == "https:":
108+
s = ussl.wrap_socket(s)
109+
if warn_ussl:
110+
print("Warning: %s SSL certificate is not validated" % host)
111+
warn_ussl = False
112+
113+
# MicroPython rawsocket module supports file interface directly
114+
s.write("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (urlpath, host))
115+
l = s.readline()
116+
protover, status, msg = l.split(None, 2)
117+
if status != b"200":
118+
raise OSError()
119+
while 1:
116120
l = s.readline()
117-
protover, status, msg = l.split(None, 2)
118-
if status != b"200":
121+
if not l:
119122
raise OSError()
120-
while 1:
121-
l = s.readline()
122-
if not l:
123-
raise OSError()
124-
if l == b'\r\n':
125-
break
126-
127-
return s
128-
129-
except ImportError:
130-
131-
def download(url, local_name):
132-
if debug:
133-
print("wget -q %s -O %s" % (url, local_name))
134-
rc = os.system("wget -q %s -O %s" % (url, local_name))
135-
if local_name not in cleanup_files:
136-
cleanup_files.append(local_name)
137-
if rc == 8 * 256:
138-
raise NotFoundError
123+
if l == b'\r\n':
124+
break
125+
126+
return s
139127

140128

141129
def get_pkg_metadata(name):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy