]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Add 'run_command' action
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 27 Jul 2016 08:10:30 +0000 (10:10 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 27 Jul 2016 08:12:59 +0000 (10:12 +0200)
helpers/actions/__init__.py
helpers/actions/command.py [deleted file]
helpers/actions/run_command.py [new file with mode: 0644]

index ea1e800d9ada4ea89ae4bf81a4426b8723574a7b..658cef0883f5939637a8f3a0b2652acfeb682c59 100644 (file)
@@ -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 (file)
index 96f72fe..0000000
+++ /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 (file)
index 0000000..1e80c1e
--- /dev/null
@@ -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