添加已下载检测
This commit is contained in:
parent
52d28f42d2
commit
62f0f5291d
|
@ -1,3 +1,4 @@
|
|||
from re import T
|
||||
import time
|
||||
import os
|
||||
import shutil
|
||||
|
@ -10,14 +11,19 @@ CHUNKSIZE = 1024
|
|||
|
||||
|
||||
class Download_Theard(Thread):
|
||||
def __init__(self, url, to, progress_callback, onfinish):
|
||||
def __init__(self, url, to, progress_callback, onfinish, fname):
|
||||
self.url = url
|
||||
self.to = to
|
||||
self.progress_callback = progress_callback
|
||||
self.fname = fname
|
||||
self.onfinish = onfinish
|
||||
Thread.__init__(self, daemon=True)
|
||||
|
||||
def run(self):
|
||||
finished = False
|
||||
if (os.path.exists("software"+os.sep+self.fname)):
|
||||
self.onfinish()
|
||||
finished = True
|
||||
while 1:
|
||||
try:
|
||||
info("[downloader]download "+self.url)
|
||||
|
@ -37,6 +43,7 @@ class Download_Theard(Thread):
|
|||
with py7zr.SevenZipFile(self.to, mode='r') as z:
|
||||
z.extractall(path="software")
|
||||
self.progress_callback(1)
|
||||
if (finished == False):
|
||||
self.onfinish()
|
||||
return
|
||||
except:
|
||||
|
@ -60,5 +67,5 @@ def download_files(files, onfisish, anim_list):
|
|||
|
||||
for i in files:
|
||||
threads.append(Download_Theard(
|
||||
i["from"], i["to"], i["progbar"], progfinish))
|
||||
i["from"], i["to"], i["progbar"], progfinish, i["name"]))
|
||||
threads[-1].start()
|
||||
|
|
|
@ -84,7 +84,8 @@ def change_page_download():
|
|||
download_l.append({
|
||||
"from": i["source"],
|
||||
"to": "software"+os.sep+"cache"+os.sep+i["name"]+".7z",
|
||||
"progbar": funclst[-1]
|
||||
"progbar": funclst[-1],
|
||||
"name": i["name"]
|
||||
})
|
||||
runf()
|
||||
|
||||
|
|
Loading…
Reference in New Issue