]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blobdiff - helpers/actions/run_command.py
Add 'run_command' action
[perso/Immae/Projets/Python/MusicSampler.git] / helpers / actions / run_command.py
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