mirror of
https://github.com/chocolate-doom/statcheck.git
synced 2024-11-25 13:51:12 +00:00
39 lines
974 B
Python
Executable file
39 lines
974 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import os
|
|
from os.path import dirname, basename, join, exists
|
|
import shlex
|
|
import sys
|
|
import yaml
|
|
|
|
def read_config(path):
|
|
if path == '':
|
|
return {}
|
|
|
|
# Config deeper in the hierarchy can override config files from
|
|
# higher up in the hierarchy:
|
|
result = read_config(dirname(path))
|
|
config_file = join(path, ".democonfig")
|
|
if exists(config_file):
|
|
with open(config_file) as f:
|
|
result.update(yaml.safe_load(f))
|
|
|
|
return result
|
|
|
|
source_port = os.getenv("SOURCE_PORT")
|
|
assert source_port != "", "SOURCE_PORT environment variable not set."
|
|
lmp_file, out_file = sys.argv[1:]
|
|
cfg = read_config(lmp_file)
|
|
|
|
args = [
|
|
source_port, "-iwad", cfg["iwad"],
|
|
"-statdump", out_file,
|
|
"-timedemo", lmp_file,
|
|
] + shlex.split(os.getenv("DOOMOPTS", ""))
|
|
|
|
if "pwad" in cfg:
|
|
args.extend(("-file", join("extract", cfg["pwad"])))
|
|
|
|
print(shlex.join(args))
|
|
sys.stdout.close()
|
|
os.spawnvp(os.P_WAIT, args[0], args)
|