From: Ismaƫl Bouya Date: Wed, 27 Jul 2016 08:10:30 +0000 (+0200) Subject: Add 'run_command' action X-Git-Tag: 1.0.0~11 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git;a=commitdiff_plain;h=df9ddd346b801ed4f69b0637eb82124accef9ada Add 'run_command' action --- diff --git a/helpers/actions/__init__.py b/helpers/actions/__init__.py index ea1e800..658cef0 100644 --- a/helpers/actions/__init__.py +++ b/helpers/actions/__init__.py @@ -1,7 +1,7 @@ -from . import command from . import interrupt_wait from . import pause from . import play +from . import run_command from . import seek from . import stop from . import stop_all_actions diff --git a/helpers/actions/command.py b/helpers/actions/command.py deleted file mode 100644 index 96f72fe..0000000 --- a/helpers/actions/command.py +++ /dev/null @@ -1,6 +0,0 @@ -def run(action, command="", **kwargs): - # FIXME: todo - pass - -def description(action, command="", **kwargs): - return "running command {}".format(command) diff --git a/helpers/actions/run_command.py b/helpers/actions/run_command.py new file mode 100644 index 0000000..1e80c1e --- /dev/null +++ b/helpers/actions/run_command.py @@ -0,0 +1,13 @@ +import shlex, subprocess + +def run(action, command="", wait=False, **kwargs): + action.process = subprocess.Popen(command, shell=True) + if wait: + action.process.wait() + +def description(action, command="", wait=False, **kwargs): + message = "running command {}".format(command) + if wait: + message += " (waiting for its execution to finish)" + + return message