diff --git a/libs/core/__init__.py b/libs/core/__init__.py index eb825c2..0a4cfcc 100644 --- a/libs/core/__init__.py +++ b/libs/core/__init__.py @@ -22,6 +22,9 @@ os_type = "" # 输出路径 output_path = "" +# 下载完成标记 +download_flag = False + class Bootstrapper(object): def __init__(self, path): @@ -39,6 +42,7 @@ class Bootstrapper(object): global domain_history_path global excel_row global download_path + global download_flag create_time = time.strftime("%Y%m%d%H%M%S", time.localtime()) diff --git a/libs/core/download.py b/libs/core/download.py index 57a78da..081eb95 100644 --- a/libs/core/download.py +++ b/libs/core/download.py @@ -14,11 +14,12 @@ from requests.adapters import HTTPAdapter class DownloadThreads(threading.Thread): - def __init__(self,input_path,cache_path,types): + def __init__(self,input_path,file_name,cache_path,types): threading.Thread.__init__(self) self.url = input_path self.types = types self.cache_path = cache_path + self.file_name = file_name def __requset__(self): try: @@ -45,11 +46,11 @@ class DownloadThreads(threading.Thread): if chunk: f.write(chunk) count += len(chunk) - if time.time() - time1 > 2: + if time.time() - time1 > 1: p = count / length * 100 speed = (count - count_tmp) / 1024 / 1024 / 2 - count_tmp = count - print(name + ': ' + formatFloat(p) + '%' + ' Speed: ' + formatFloat(speed) + 'M/S') + # count_tmp = count + print(self.file_name + ': ' + formatFloat(p) + '%' + ' Speed: ' + formatFloat(speed) + 'M/S') time1 = time.time() f.close() else: @@ -57,11 +58,11 @@ class DownloadThreads(threading.Thread): with open(self.cache_path,"w",encoding='utf-8',errors='ignore') as f: f.write(html) f.close() - else: - return + cores.download_flag = True except Exception: return - + def formatFloat(num): + return '{:.2f}'.format(num) def run(self): threadLock = threading.Lock() diff --git a/libs/task/base_task.py b/libs/task/base_task.py index 38d56b6..a0a605d 100644 --- a/libs/task/base_task.py +++ b/libs/task/base_task.py @@ -77,7 +77,7 @@ class BaseTask(object): cache_info = DownloadTask().start(self.path,self.types) cacar_path = cache_info["path"] types = cache_info["type"] - if not os.path.exists(cacar_path): + if not os.path.exists(cacar_path) and cores.download_flag: print("[-] File download failed! Please download the file manually and try again.") return task_info diff --git a/libs/task/download_task.py b/libs/task/download_task.py index 17da233..dc4024a 100644 --- a/libs/task/download_task.py +++ b/libs/task/download_task.py @@ -16,13 +16,13 @@ class DownloadTask(object): create_time = time.strftime("%Y%m%d%H%M%S", time.localtime()) if path.endswith("apk"): types = "Android" - file_suffix = ".apk" + file_name = create_time+ ".apk" elif path.endswith("ipa"): types = "iOS" - file_suffix = ".ipa" + file_name = create_time + ".ipa" else: types = "WEB" - file_suffix = ".html" + file_name = create_time + ".html" if not(path.startswith("http://") or path.startswith("https://")): if not os.path.isdir(path): @@ -31,8 +31,8 @@ class DownloadTask(object): return {"path":self.path,"type":self.types} else: print("[*] Detected that the task is not local, preparing to download file......") - cache_path = os.path.join(cores.download_path, create_time + file_suffix) - thread = DownloadThreads(path,cache_path,types) + cache_path = os.path.join(cores.download_path, file_name) + thread = DownloadThreads(path,file_name,cache_path,types) thread.start() thread.join()