diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-27 10:10:30 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-27 10:12:59 +0200 |
commit | df9ddd346b801ed4f69b0637eb82124accef9ada (patch) | |
tree | 18745acfbb3d6c194819a5dae6cd0d07d54b2d59 /helpers/actions/run_command.py | |
parent | 940bb6ad6cbd823ed245577093bd8959e189d43f (diff) | |
download | MusicSampler-df9ddd346b801ed4f69b0637eb82124accef9ada.tar.gz MusicSampler-df9ddd346b801ed4f69b0637eb82124accef9ada.tar.zst MusicSampler-df9ddd346b801ed4f69b0637eb82124accef9ada.zip |
Add 'run_command' action
Diffstat (limited to 'helpers/actions/run_command.py')
-rw-r--r-- | helpers/actions/run_command.py | 13 |
1 files changed, 13 insertions, 0 deletions
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 @@ | |||
1 | import shlex, subprocess | ||
2 | |||
3 | def run(action, command="", wait=False, **kwargs): | ||
4 | action.process = subprocess.Popen(command, shell=True) | ||
5 | if wait: | ||
6 | action.process.wait() | ||
7 | |||
8 | def 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 | ||