From df9ddd346b801ed4f69b0637eb82124accef9ada Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 27 Jul 2016 10:10:30 +0200 Subject: [PATCH] Add 'run_command' action --- helpers/actions/__init__.py | 2 +- helpers/actions/command.py | 6 ------ helpers/actions/run_command.py | 13 +++++++++++++ 3 files changed, 14 insertions(+), 7 deletions(-) delete mode 100644 helpers/actions/command.py create mode 100644 helpers/actions/run_command.py 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 -- 2.41.0