doomcc/dcc/fabricate.py
yrriban edbf4f2a0e Use os.execv instead of subprocess.run when no further action is taken.
This prevents the underlying file from being marked busy while a
long-running action is happening (e.g. eureka is open).
2025-12-24 18:09:49 -05:00

31 lines
1,014 B
Python

import contextlib
import dcc.config
import dcc.doom_base
import os
import shutil
import tempfile
class Fabricate(dcc.doom_base.WadMap):
def get_parser(self, prog_name):
parser = super().get_parser(prog_name)
parser.add_argument("--fg", action="store_true")
return parser
def take_action(self, parsed_args):
with tempfile.TemporaryDirectory() as td:
with contextlib.chdir(td):
command = [self.dsda]
if not parsed_args.fg and shutil.which("xvfb-run") is not None:
command = ["xvfb-run"] + command
os.execvp(command[0],
command + self.dsda_preamble()
+ ["-timedemo", self.demo_in_path()]
+ ["-viddump", self.video_path()]
)
def options_dict(self):
opt_dict = super().options_dict()
for k, v in self._config.get("fabricate_options", {}).items():
opt_dict[k] = v
return opt_dict