copy file to jaymod dir
This commit is contained in:
parent
91ba9cb6a0
commit
26ff59eb8d
@ -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()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user