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 | |
parent | 940bb6ad6cbd823ed245577093bd8959e189d43f (diff) | |
download | MusicSampler-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__.py | 2 | ||||
-rw-r--r-- | helpers/actions/command.py | 6 | ||||
-rw-r--r-- | helpers/actions/run_command.py | 13 |
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 @@ | |||
1 | from . import command | ||
2 | from . import interrupt_wait | 1 | from . import interrupt_wait |
3 | from . import pause | 2 | from . import pause |
4 | from . import play | 3 | from . import play |
4 | from . import run_command | ||
5 | from . import seek | 5 | from . import seek |
6 | from . import stop | 6 | from . import stop |
7 | from . import stop_all_actions | 7 | from . 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 @@ | |||
1 | def run(action, command="", **kwargs): | ||
2 | # FIXME: todo | ||
3 | pass | ||
4 | |||
5 | def 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 @@ | |||
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 | ||