]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blobdiff - music_sampler/actions/run_command.py
Rename helpers to music_sampler
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler / actions / run_command.py
diff --git a/music_sampler/actions/run_command.py b/music_sampler/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