import time import os import shutil from threading import Thread from logger.logger import * class PKG_Theard(Thread): def __init__(self, disks, barcallback, donecallback): self.disks = disks self.barcallback = barcallback self.donecallback = donecallback Thread.__init__(self, daemon=True) def run(self): DISK = self.disks info(f"[install]install to {DISK}") self.barcallback(0) if not os.path.exists(DISK+"/PEinjector"): os.mkdir(DISK+"/PEinjector") time.sleep(0.1) self.barcallback(0.1) info("[install]install main file") if os.path.exists(DISK+"/PEinjector/PEinjector.7z"): os.remove(DISK+"/PEinjector/PEinjector.7z") time.sleep(0.1) self.barcallback(0.2) shutil.copyfile("software/peinjector/dist/PEinjector.7z", DISK+"/PEinjector/PEinjector.7z") time.sleep(0.1) self.barcallback(0.4) time.sleep(0.1) info("[install]write info") if not os.path.exists(DISK+"/PEinjector/disable.txt"): with open(DISK+"/PEinjector/disable.txt", "w") as file: pass self.barcallback(0.5) time.sleep(0.1) shutil.copyfile("software/peinjector/version", DISK+"/PEinjector/VERSION") if not os.path.exists(DISK+"/PEinjector/install"): os.mkdir(DISK+"/PEinjector/install") self.barcallback(0.6) if not os.path.exists(DISK+"/PEinjector/package"): os.mkdir(DISK+"/PEinjector/package") ns = 0 for i in os.listdir("software/peinjector/package"): if os.path.exists(DISK+"/PEinjector/package/"+i): shutil.rmtree(DISK+"/PEinjector/package/"+i) shutil.copytree("software/peinjector/package/" + i, DISK+"/PEinjector/package/"+i) ns += 1 info( f"[install]install pkg {ns}/{len(os.listdir('software/peinjector/package'))}") self.barcallback( 0.6+ns/len(os.listdir("software/peinjector/package"))*0.4) time.sleep(0.1) info("[install]install finish") self.barcallback(1) self.donecallback()