aboutsummaryrefslogtreecommitdiff
path: root/helpers/actions
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-27 10:10:30 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-27 10:12:59 +0200
commitdf9ddd346b801ed4f69b0637eb82124accef9ada (patch)
tree18745acfbb3d6c194819a5dae6cd0d07d54b2d59 /helpers/actions
parent940bb6ad6cbd823ed245577093bd8959e189d43f (diff)
downloadMusicSampler-df9ddd346b801ed4f69b0637eb82124accef9ada.tar.gz
MusicSampler-df9ddd346b801ed4f69b0637eb82124accef9ada.tar.zst
MusicSampler-df9ddd346b801ed4f69b0637eb82124accef9ada.zip
Add 'run_command' action
Diffstat (limited to 'helpers/actions')
-rw-r--r--helpers/actions/__init__.py2
-rw-r--r--helpers/actions/command.py6
-rw-r--r--helpers/actions/run_command.py13
3 files changed, 14 insertions, 7 deletions
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 @@
1from . import command
2from . import interrupt_wait 1from . import interrupt_wait
3from . import pause 2from . import pause
4from . import play 3from . import play
4from . import run_command
5from . import seek 5from . import seek
6from . import stop 6from . import stop
7from . import stop_all_actions 7from . 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 @@
1def run(action, command="", **kwargs):
2 # FIXME: todo
3 pass
4
5def description(action, command="", **kwargs):
6 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 @@
1import shlex, subprocess
2
3def run(action, command="", wait=False, **kwargs):
4 action.process = subprocess.Popen(command, shell=True)
5 if wait:
6 action.process.wait()
7
8def description(action, command="", wait=False, **kwargs):
9 message = "running command {}".format(command)
10 if wait:
11 message += " (waiting for its execution to finish)"
12
13 return message