fix vanilla downloader
This commit is contained in:
parent
582a4eaf6c
commit
a8ca0b11bf
@ -56,19 +56,27 @@ class downloadThread(QtCore.QThread):
|
||||
self.finished.emit()
|
||||
return
|
||||
|
||||
latest_version = manifest["versions"][0]["version"]
|
||||
print latest_version
|
||||
link = ""
|
||||
check_hash = ""
|
||||
for actions in manifest["versions"][0]["full"]:
|
||||
downloads = []
|
||||
selected_version = 0
|
||||
while not "full" in manifest["versions"][selected_version]:
|
||||
version = manifest["versions"][selected_version]
|
||||
|
||||
if "update" in version:
|
||||
for actions in version["update"]:
|
||||
if actions["action"] == "dl":
|
||||
link = actions["url"]
|
||||
check_hash = actions["hash"]
|
||||
print link
|
||||
downloads.insert(0, [version["version"], actions["url"], actions["hash"]])
|
||||
print "update:\t"+repr(downloads[0])
|
||||
break
|
||||
|
||||
#link = "http://somepeople.ddns.net/headbot/song.zip"
|
||||
selected_version += 1
|
||||
|
||||
for actions in manifest["versions"][selected_version]["full"]:
|
||||
if actions["action"] == "dl":
|
||||
downloads.insert(0, [manifest["versions"][selected_version]["version"], actions["url"], actions["hash"]])
|
||||
print "full:\t"+repr(downloads[0])
|
||||
break
|
||||
|
||||
for version, link, check_hash in downloads:
|
||||
resume_bytes = 0
|
||||
filename = os.path.basename(link)
|
||||
download_it = True
|
||||
@ -87,7 +95,7 @@ class downloadThread(QtCore.QThread):
|
||||
downloadfile.close()
|
||||
|
||||
if download_it:
|
||||
self.labelText.emit("Downloading version '%s'..." % latest_version)
|
||||
self.labelText.emit("Downloading version '%s'..." % version)
|
||||
dl = resume_bytes
|
||||
speed = 0.0
|
||||
start = time.clock()
|
||||
@ -106,12 +114,12 @@ class downloadThread(QtCore.QThread):
|
||||
percent = 100 * dl / length
|
||||
if percent != self.jm.value():
|
||||
self.progressValue.emit(percent)
|
||||
self.labelText.emit("Downloading version '%s'... %.1f KB/s" % (latest_version, speed))
|
||||
self.labelText.emit("Downloading version '%s'... %.1f KB/s" % (version, speed))
|
||||
|
||||
if (time.time() - calcspeed_time) >= 0.5:
|
||||
calcspeed_time = time.time()
|
||||
speed = ((dl-resume_bytes)/(time.clock() - start)) / 1024.
|
||||
self.labelText.emit("Downloading version '%s'... %.1f KB/s" % (latest_version, speed))
|
||||
self.labelText.emit("Downloading version '%s'... %.1f KB/s" % (version, speed))
|
||||
|
||||
print "downloaded"
|
||||
downloadfile.close()
|
||||
|
Loading…
Reference in New Issue
Block a user