Fix update download on some platforms with broken ssl
This commit is contained in:
parent
69d919d3c4
commit
9a57b5a01d
1 changed files with 10 additions and 7 deletions
15
update.py
15
update.py
|
@ -12,16 +12,13 @@ monkey.patch_all()
|
||||||
|
|
||||||
|
|
||||||
def update():
|
def update():
|
||||||
# Gevent https bug workaround (https://github.com/gevent/gevent/issues/477)
|
from src.util import helper
|
||||||
reload(socket)
|
|
||||||
reload(httplib)
|
|
||||||
reload(ssl)
|
|
||||||
|
|
||||||
print "Downloading.",
|
print "Downloading.",
|
||||||
file = urllib.urlopen("https://github.com/HelloZeroNet/ZeroNet/archive/master.zip")
|
req = helper.httpRequest("https://github.com/HelloZeroNet/ZeroNet/archive/master.zip")
|
||||||
data = StringIO.StringIO()
|
data = StringIO.StringIO()
|
||||||
while True:
|
while True:
|
||||||
buff = file.read(1024 * 16)
|
buff = req.read(1024 * 16)
|
||||||
if not buff:
|
if not buff:
|
||||||
break
|
break
|
||||||
data.write(buff)
|
data.write(buff)
|
||||||
|
@ -40,7 +37,12 @@ def update():
|
||||||
print "Plugins enabled:", plugins_enabled, "disabled:", plugins_disabled
|
print "Plugins enabled:", plugins_enabled, "disabled:", plugins_disabled
|
||||||
|
|
||||||
print "Extracting...",
|
print "Extracting...",
|
||||||
|
try:
|
||||||
zip = zipfile.ZipFile(data)
|
zip = zipfile.ZipFile(data)
|
||||||
|
except Exception, err:
|
||||||
|
data.seek(0)
|
||||||
|
print "Unpack error", err, data.read()
|
||||||
|
return False
|
||||||
for inner_path in zip.namelist():
|
for inner_path in zip.namelist():
|
||||||
if ".." in inner_path:
|
if ".." in inner_path:
|
||||||
continue
|
continue
|
||||||
|
@ -73,6 +75,7 @@ def update():
|
||||||
print dest_path, err
|
print dest_path, err
|
||||||
|
|
||||||
print "Done."
|
print "Done."
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue