60 lines
1.4 KiB
Python
60 lines
1.4 KiB
Python
import logging
|
|
import os
|
|
import platform
|
|
import shutil
|
|
import time
|
|
import urllib3
|
|
|
|
FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
|
|
logging.basicConfig(format=FORMAT, level=logging.INFO)
|
|
|
|
URL = "http://et.thegux.fr/jaymod/"
|
|
FILES = (
|
|
"1944_beach.pk3",
|
|
"baserace.pk3",
|
|
"caen.pk3",
|
|
"goldendunk_a2.pk3",
|
|
"jaymod-2.2.0.pk3",
|
|
"mlb_temple.pk3",
|
|
"nfl_b2.pk3",
|
|
"saberpeak_final.pk3",
|
|
"supergoldrush_final.pk3",
|
|
"supply_depot_2.pk3",
|
|
"tc_base.pk3",
|
|
"v2base_te.pk3",
|
|
"venice.pk3",
|
|
)
|
|
|
|
|
|
def get_file(filename: str, outdir: str):
|
|
with open(os.path.join(outdir, filename), "wb") as out:
|
|
r = urllib3.request("GET", f"{URL}/{filename}", preload_content=False)
|
|
shutil.copyfileobj(r, out)
|
|
|
|
|
|
def create_jaymod_directory() -> str:
|
|
name = platform.system()
|
|
if name == "Windows":
|
|
path = os.path.join(
|
|
"C:", "Program Files (x86)", "Wolfenstein - Enemy Territory", "jaymod"
|
|
)
|
|
os.makedirs(path, exist_ok=True)
|
|
return path
|
|
raise Exception("platform not supported")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
start = time.perf_counter()
|
|
logging.info("installing Thegux Jaymod...")
|
|
|
|
try:
|
|
jaymod_dir = create_jaymod_directory()
|
|
except Exception as e:
|
|
logging.fatal(e)
|
|
exit(1)
|
|
|
|
for f in FILES:
|
|
get_file(f, jaymod_dir)
|
|
|
|
logging.info(f"elapsed time: {time.perf_counter() - start:.2f}s")
|