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