@@ -90,52 +90,40 @@ def expandhome(s):
90
90
s = s .replace ("~/" , h + "/" )
91
91
return s
92
92
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 \n Host: %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 \n Host: %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 :
116
120
l = s .readline ()
117
- protover , status , msg = l .split (None , 2 )
118
- if status != b"200" :
121
+ if not l :
119
122
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
139
127
140
128
141
129
def get_pkg_metadata (name ):
0 commit comments