Use os.execv instead of subprocess.run when no further action is taken. #11
7 changed files with 23 additions and 25 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import dcc.doom_base
|
import dcc.doom_base
|
||||||
import dcc.config
|
import dcc.config
|
||||||
import subprocess
|
import os
|
||||||
|
|
||||||
|
|
||||||
class Eureka(dcc.doom_base.WadMap):
|
class Eureka(dcc.doom_base.WadMap):
|
||||||
|
|
@ -24,7 +24,7 @@ class Eureka(dcc.doom_base.WadMap):
|
||||||
if complevel == "11" or complevel == "21":
|
if complevel == "11" or complevel == "21":
|
||||||
port = "mbf"
|
port = "mbf"
|
||||||
|
|
||||||
subprocess.run(
|
os.execvp("eureka",
|
||||||
["eureka"] + ["-iwad", iwad] + ["-w", parsed_args.map]
|
["eureka"] + ["-iwad", iwad] + ["-w", parsed_args.map]
|
||||||
+ ["-p", port] + [mw]
|
+ ["-p", port] + [mw]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import contextlib
|
import contextlib
|
||||||
import dcc.config
|
import dcc.config
|
||||||
import dcc.doom_base
|
import dcc.doom_base
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ class Fabricate(dcc.doom_base.WadMap):
|
||||||
command = [self.dsda]
|
command = [self.dsda]
|
||||||
if not parsed_args.fg and shutil.which("xvfb-run") is not None:
|
if not parsed_args.fg and shutil.which("xvfb-run") is not None:
|
||||||
command = ["xvfb-run"] + command
|
command = ["xvfb-run"] + command
|
||||||
subprocess.run(
|
os.execvp(command[0],
|
||||||
command + self.dsda_preamble()
|
command + self.dsda_preamble()
|
||||||
+ ["-timedemo", self.demo_in_path()]
|
+ ["-timedemo", self.demo_in_path()]
|
||||||
+ ["-viddump", self.video_path()]
|
+ ["-viddump", self.video_path()]
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import dcc.config
|
import dcc.config
|
||||||
import dcc.doom_base
|
import dcc.doom_base
|
||||||
import subprocess
|
import os
|
||||||
|
|
||||||
|
|
||||||
class PB(dcc.doom_base.WadMap):
|
class PB(dcc.doom_base.WadMap):
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
subprocess.run(["ffplay", self.video_path()])
|
os.execvp("ffplay", ["ffplay", self.video_path()])
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import dcc.config
|
import dcc.config
|
||||||
import dcc.doom_base
|
import dcc.doom_base
|
||||||
import subprocess
|
import os
|
||||||
|
|
||||||
|
|
||||||
class Play(dcc.doom_base.WadMap):
|
class Play(dcc.doom_base.WadMap):
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
subprocess.run([self.dsda] + self.dsda_preamble())
|
os.execv(self.dsda, [self.dsda] + self.dsda_preamble())
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import dcc.config
|
import dcc.config
|
||||||
import dcc.doom_base
|
import dcc.doom_base
|
||||||
import subprocess
|
import os
|
||||||
|
|
||||||
|
|
||||||
class Record(dcc.doom_base.WadMap):
|
class Record(dcc.doom_base.WadMap):
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
subprocess.run(
|
os.execv(self.dsda,
|
||||||
[self.dsda] + self.dsda_preamble() +
|
[self.dsda] + self.dsda_preamble() +
|
||||||
["-record", self.demo_out_path()]
|
["-record", self.demo_out_path()]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import dcc.doom_base
|
import dcc.doom_base
|
||||||
import pathlib
|
import pathlib
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -42,7 +41,7 @@ class RIB(dcc.doom_base.WadMap):
|
||||||
+ f"and map {parsed_args.map} (tried to look in {demodir})"
|
+ f"and map {parsed_args.map} (tried to look in {demodir})"
|
||||||
)
|
)
|
||||||
|
|
||||||
subprocess.run(
|
os.execv(self.dsda,
|
||||||
[self.dsda] + self.dsda_preamble(warp=False)
|
[self.dsda] + self.dsda_preamble(warp=False)
|
||||||
+ ["-playdemo", demo]
|
+ ["-playdemo", demo]
|
||||||
+ ["-skiptic", str(-35 * parsed_args.secs_before)]
|
+ ["-skiptic", str(-35 * parsed_args.secs_before)]
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
import cliff.app
|
import cliff.app
|
||||||
import dcc.play
|
import dcc.play
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import mockito.matchers
|
import mockito.matchers
|
||||||
import pathlib
|
import pathlib
|
||||||
import subprocess
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def test_play(when):
|
def test_play(expect):
|
||||||
with tempfile.TemporaryDirectory() as td:
|
with tempfile.TemporaryDirectory() as td:
|
||||||
tdp = pathlib.Path(td)
|
tdp = pathlib.Path(td)
|
||||||
tdp.joinpath("config.toml").write_text(
|
tdp.joinpath("config.toml").write_text(
|
||||||
|
|
@ -26,9 +26,14 @@ def test_play(when):
|
||||||
scp.mkdir()
|
scp.mkdir()
|
||||||
scp.joinpath("config.toml").touch()
|
scp.joinpath("config.toml").touch()
|
||||||
scp.joinpath("scythe.wad").touch()
|
scp.joinpath("scythe.wad").touch()
|
||||||
zero = subprocess.CompletedProcess
|
dcc.play.Play.__init__ = lambda self: None
|
||||||
zero.returncode = 0
|
dcc.play.Play.get_epilog = lambda self: ""
|
||||||
when(subprocess).run(
|
rig = dcc.play.Play()
|
||||||
|
rig._hooks = []
|
||||||
|
parser = rig.get_parser("test_play")
|
||||||
|
parsed_args = parser.parse_args(args=["--doom", td, "scythe", "01"])
|
||||||
|
with expect(os, times=1).execv(
|
||||||
|
tdp.joinpath("dsda-doom").joinpath("exe"),
|
||||||
[
|
[
|
||||||
tdp.joinpath("dsda-doom").joinpath("exe"),
|
tdp.joinpath("dsda-doom").joinpath("exe"),
|
||||||
"-iwad",
|
"-iwad",
|
||||||
|
|
@ -42,11 +47,5 @@ def test_play(when):
|
||||||
"-warp",
|
"-warp",
|
||||||
"01",
|
"01",
|
||||||
]
|
]
|
||||||
).thenReturn(zero)
|
).thenReturn(None):
|
||||||
dcc.play.Play.__init__ = lambda self: None
|
assert rig.run(parsed_args) is None
|
||||||
dcc.play.Play.get_epilog = lambda self: ""
|
|
||||||
rig = dcc.play.Play()
|
|
||||||
rig._hooks = []
|
|
||||||
parser = rig.get_parser("test_play")
|
|
||||||
parsed_args = parser.parse_args(args=["--doom", td, "scythe", "01"])
|
|
||||||
assert rig.run(parsed_args) == 0
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue