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