2015-02-20 01:37:12 +01:00
|
|
|
from gevent import monkey; monkey.patch_all()
|
2015-03-31 00:02:02 +02:00
|
|
|
import urllib, zipfile, os, ssl, httplib, socket, re
|
2015-02-20 01:37:12 +01:00
|
|
|
import cStringIO as StringIO
|
|
|
|
|
|
|
|
def update():
|
|
|
|
# Gevent https bug workaround (https://github.com/gevent/gevent/issues/477)
|
|
|
|
reload(socket)
|
|
|
|
reload(httplib)
|
|
|
|
reload(ssl)
|
|
|
|
|
|
|
|
print "Downloading.",
|
|
|
|
file = urllib.urlopen("https://github.com/HelloZeroNet/ZeroNet/archive/master.zip")
|
|
|
|
data = StringIO.StringIO()
|
|
|
|
while True:
|
|
|
|
buff = file.read(1024*16)
|
|
|
|
if not buff: break
|
|
|
|
data.write(buff)
|
|
|
|
print ".",
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
print "Downloaded."
|
|
|
|
|
|
|
|
# Checking plugins
|
|
|
|
plugins_enabled = []
|
|
|
|
plugins_disabled = []
|
|
|
|
if os.path.isdir("plugins"):
|
|
|
|
for dir in os.listdir("plugins"):
|
|
|
|
if dir.startswith("disabled-"):
|
|
|
|
plugins_disabled.append(dir.replace("disabled-", ""))
|
|
|
|
else:
|
|
|
|
plugins_enabled.append(dir)
|
2015-03-31 00:09:25 +02:00
|
|
|
print "Plugins enabled:", plugins_enabled, "disabled:", plugins_disabled
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
|
2015-02-20 01:37:12 +01:00
|
|
|
|
|
|
|
print "Extracting...",
|
|
|
|
zip = zipfile.ZipFile(data)
|
|
|
|
for inner_path in zip.namelist():
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
inner_path = inner_path.replace("\\", "/") # Make sure we have unix path
|
2015-02-20 01:37:12 +01:00
|
|
|
print ".",
|
|
|
|
dest_path = inner_path.replace("ZeroNet-master/", "")
|
|
|
|
if not dest_path: continue
|
|
|
|
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
|
|
|
|
# Keep plugin disabled/enabled status
|
|
|
|
match = re.match("plugins/([^/]+)", dest_path)
|
|
|
|
if match:
|
|
|
|
plugin_name = match.group(1).replace("disabled-","")
|
|
|
|
if plugin_name in plugins_enabled: # Plugin was enabled
|
|
|
|
dest_path = dest_path.replace("plugins/disabled-"+plugin_name, "plugins/"+plugin_name)
|
2015-03-31 00:09:25 +02:00
|
|
|
elif plugin_name in plugins_disabled: # Plugin was disabled
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
dest_path = dest_path.replace("plugins/"+plugin_name, "plugins/disabled-"+plugin_name)
|
|
|
|
print "P",
|
|
|
|
|
2015-02-20 01:37:12 +01:00
|
|
|
dest_dir = os.path.dirname(dest_path)
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
|
2015-02-20 01:37:12 +01:00
|
|
|
if dest_dir and not os.path.isdir(dest_dir):
|
|
|
|
os.makedirs(dest_dir)
|
|
|
|
|
|
|
|
if dest_dir != dest_path.strip("/"):
|
|
|
|
data = zip.read(inner_path)
|
version 0.3.0, rev187, Trusted authorization sites support, --publish option on signing, cryptSign command line option, OpenSSL enabled on OSX, Crypto verify allows list of valid addresses, Option for version 2 json DB tables, DbCursor SELECT parameters bugfix, Add peer to site on ListModified, Download blind includes when new site added, Publish command better messages, Multi-threaded announce, New http Torrent trackers, Wait for dbschema.json on query, Handle json import errors, More compact writeJson storage command, Testcase for signing and verifying, Workaround to make non target=_top links work, More clean UiWebsocket command route, Send cert_user_id on siteinfo, Notify other local clients on local file modify, Option to wait for file download before sql query, File rules websocket API command, Cert add and select, set websocket API command, Put focus on innerframe, innerloaded wrapper api command to add hashtag, Allow more file error on big sites, Keep worker running after stuked on done task, New more stable openSSL layer that works on OSX, Noparallel parameter bugfix, RateLimit allowed again interval bugfix, Updater skips non-writeable files, Try to close openssl dll before update
2015-05-25 01:26:33 +02:00
|
|
|
try:
|
|
|
|
open(dest_path, 'wb').write(data)
|
|
|
|
except Exception, err:
|
|
|
|
print dest_path, err
|
2015-02-20 01:37:12 +01:00
|
|
|
|
|
|
|
print "Done."
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2015-03-31 00:02:02 +02:00
|
|
|
try:
|
|
|
|
update()
|
|
|
|
except Exception, err:
|
|
|
|
print "Update error: %s" % err
|
|
|
|
raw_input("Press enter to exit")
|