def update(): from src.util import helper print "Downloading.", req = helper.httpRequest( "https://github.com/HelloZeroNet/ZeroNet/archive/master.zip") data = StringIO.StringIO() while True: buff = req.read(1024 * 16) if not buff: break data.write(buff) print ".", 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) print "Plugins enabled:", plugins_enabled, "disabled:", plugins_disabled print "Extracting...", try: zip = zipfile.ZipFile(data) except Exception, err: data.seek(0) print "Unpack error", err, data.read() return False
def update(): from src.util import helper print "Downloading.", req = helper.httpRequest("https://github.com/shiftcurrency/phantom") data = StringIO.StringIO() while True: buff = req.read(1024 * 16) if not buff: break data.write(buff) print ".", 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) print "Plugins enabled:", plugins_enabled, "disabled:", plugins_disabled print "Extracting...", try: zip = zipfile.ZipFile(data) except Exception, err: data.seek(0) print "Unpack error", err, data.read() return False
def download(): from src.util import helper urls = [ "https://github.com/HelloZeroNet/ZeroNet/archive/master.zip", "https://gitlab.com/HelloZeroNet/ZeroNet/repository/archive.zip?ref=master", "https://try.gogs.io/ZeroNet/ZeroNet/archive/master.zip" ] zipdata = None for url in urls: print "Downloading from:", url, try: req = helper.httpRequest(url) data = StringIO.StringIO() while True: buff = req.read(1024 * 16) if not buff: break data.write(buff) print ".", try: zipdata = zipfile.ZipFile(data) break # Success except Exception, err: data.seek(0) print "Unpack error", err, data.read(256) except Exception, err: print "Error downloading update from %s: %s" % (url, err)