From 6b66064831e502a9cc2f97f6e1746ff0ebb4219b Mon Sep 17 00:00:00 2001 From: Xodetaetl Date: Sat, 21 Mar 2015 12:12:01 +0100 Subject: [PATCH] Add args, exit and working_dir options to dosexec --- docs/installers.rst | 18 +++++++++++++++++- lutris/runners/dosbox.py | 14 ++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/docs/installers.rst b/docs/installers.rst index 8569db815..16cd104e6 100644 --- a/docs/installers.rst +++ b/docs/installers.rst @@ -275,7 +275,6 @@ Currently, the following tasks are implemented: executable: drive_c/Program Files/Game/Game.exe args: --windowed - * wine / winesteam: ``winetricks`` Runs winetricks with the ``app`` argument. ``prefix`` is an optional WINEPREFIX path. @@ -315,6 +314,23 @@ Currently, the following tasks are implemented: prefix: $GAMEDIR filename: myregfile +* dosbox: ``dosexec`` Runs dosbox. Parameters are ``executable`` (optional + ``file ID`` or path to executable), ``config_file`` + (optional ``file ID`` or path to .conf file), ``args`` (optional command + arguments), ``working_dir`` (optional working directory, defaults to the + ``executable``'s dir or the ``config_file``'s dir), ``exit`` (set to + ``false`` to prevent DOSBox to exit when the ``executable`` is terminated). + + Example: + + :: + + - task: + name: dosexec + executable: file_id + config: $GAMEDIR/game_install.conf + args: -scaler normal3x -conf more_conf.conf + Displaying a drop-down menu with options ---------------------------------------- diff --git a/lutris/runners/dosbox.py b/lutris/runners/dosbox.py index a347f852f..492849f00 100644 --- a/lutris/runners/dosbox.py +++ b/lutris/runners/dosbox.py @@ -6,16 +6,26 @@ from lutris.util.log import logger from lutris.runners.runner import Runner -def dosexec(config_file=None, executable=None): +def dosexec(config_file=None, executable=None, args=None, exit=True, + working_dir=None): """Execute Dosbox with given config_file""" logger.debug("Running dosbox with config %s" % config_file) dbx = dosbox() command = '"{}"'.format(dbx.get_executable()) if config_file: command += ' -conf "{}"'.format(config_file) + if not working_dir: + working_dir = os.path.dirname(config_file) if executable: command += ' "{}"'.format(executable) - subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).communicate() + if not working_dir: + working_dir = os.path.dirname(executable) + if args: + command += ' ' + args + if exit: + command += " -exit" + subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, + cwd=working_dir).communicate() class dosbox(Runner):