copy file to jaymod dir

This commit is contained in:
rmanach 2023-08-14 22:39:57 +02:00
parent 91ba9cb6a0
commit 26ff59eb8d

View File

@ -29,19 +29,20 @@ FILES = (
) )
def get_files(http: PoolManager, filename: str): def get_files(http: PoolManager, filename: str, outdir: str):
with open(filename, "wb") as out: with open(os.path.join(outdir, filename), "wb") as out:
r = http.request("GET", f"{URL}/{filename}", preload_content=False) r = http.request("GET", f"{URL}/{filename}", preload_content=False)
shutil.copyfileobj(r, out) shutil.copyfileobj(r, out)
def create_jaymod_directory(): def create_jaymod_directory() -> str:
name = platform.system() name = platform.system()
if name == "Windows": if name == "Windows":
path = os.path.join( path = os.path.join(
"C:", "Program Files (x86)", "Wolfenstein - Enemy Territory" "C:", "Program Files (x86)", "Wolfenstein - Enemy Territory", "jaymod"
) )
os.makedirs(path, "jaymod") os.makedirs(path, exist_ok=True)
return path
raise Exception("platform not supported") raise Exception("platform not supported")
@ -50,7 +51,7 @@ if __name__ == "__main__":
logging.info("installing Thegux Jaymod...") logging.info("installing Thegux Jaymod...")
try: try:
create_jaymod_directory() jaymod_dir = create_jaymod_directory()
except Exception as e: except Exception as e:
logging.fatal(e) logging.fatal(e)
exit(1) exit(1)
@ -59,7 +60,7 @@ if __name__ == "__main__":
http = urllib3.PoolManager() http = urllib3.PoolManager()
for f in FILES: for f in FILES:
t = Thread(target=get_files, args=[http, f]) t = Thread(target=get_files, args=[http, f, jaymod_dir])
threads.append(t) threads.append(t)
t.start() t.start()