diff --git a/install_jaymod.py b/install_jaymod.py index f541dc3..698e6df 100644 --- a/install_jaymod.py +++ b/install_jaymod.py @@ -29,19 +29,20 @@ FILES = ( ) -def get_files(http: PoolManager, filename: str): - with open(filename, "wb") as out: +def get_files(http: PoolManager, filename: str, outdir: str): + with open(os.path.join(outdir, filename), "wb") as out: r = http.request("GET", f"{URL}/{filename}", preload_content=False) shutil.copyfileobj(r, out) -def create_jaymod_directory(): +def create_jaymod_directory() -> str: name = platform.system() if name == "Windows": 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") @@ -50,7 +51,7 @@ if __name__ == "__main__": logging.info("installing Thegux Jaymod...") try: - create_jaymod_directory() + jaymod_dir = create_jaymod_directory() except Exception as e: logging.fatal(e) exit(1) @@ -59,7 +60,7 @@ if __name__ == "__main__": http = urllib3.PoolManager() 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) t.start()