diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-27 21:33:09 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-27 21:33:09 +0200 |
commit | 63ba5a8dc2aa4ec3e6f203b0ba4db249ecf0b00e (patch) | |
tree | f043ab215425aca3434bf178029dad9f9e62dbe9 /helpers/actions/wait.py | |
parent | 35bde798b6cda13579337b0ec5a803fdd5eab19a (diff) | |
download | MusicSampler-63ba5a8dc2aa4ec3e6f203b0ba4db249ecf0b00e.tar.gz MusicSampler-63ba5a8dc2aa4ec3e6f203b0ba4db249ecf0b00e.tar.zst MusicSampler-63ba5a8dc2aa4ec3e6f203b0ba4db249ecf0b00e.zip |
Rename helpers to music_sampler
Diffstat (limited to 'helpers/actions/wait.py')
-rw-r--r-- | helpers/actions/wait.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/helpers/actions/wait.py b/helpers/actions/wait.py deleted file mode 100644 index ea42408..0000000 --- a/helpers/actions/wait.py +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | import threading | ||
2 | |||
3 | def run(action, duration=0, music=None, set_wait_id=None, **kwargs): | ||
4 | if set_wait_id is not None: | ||
5 | action.mapping.add_wait_id(set_wait_id, action) | ||
6 | |||
7 | action.sleep_event = threading.Event() | ||
8 | action.sleep_event_timer = threading.Timer( | ||
9 | duration, | ||
10 | action.sleep_event.set) | ||
11 | |||
12 | if music is not None: | ||
13 | music.wait_end() | ||
14 | |||
15 | action.sleep_event_timer.start() | ||
16 | action.sleep_event.wait() | ||
17 | |||
18 | def description(action, duration=0, music=None, set_wait_id=None, **kwargs): | ||
19 | message = "" | ||
20 | if music is None: | ||
21 | message += "waiting {}s" \ | ||
22 | .format(duration) | ||
23 | elif duration == 0: | ||
24 | message += "waiting the end of « {} »" \ | ||
25 | .format(music.name) | ||
26 | else: | ||
27 | message += "waiting the end of « {} » + {}s" \ | ||
28 | .format(music.name, duration) | ||
29 | |||
30 | if set_wait_id is not None: | ||
31 | message += " (setting id = {})".format(set_wait_id) | ||
32 | |||
33 | return message | ||
34 | |||
35 | def interrupt(action, duration=0, music=None, **kwargs): | ||
36 | if action.sleep_event is not None: | ||
37 | action.sleep_event.set() | ||
38 | action.sleep_event_timer.cancel() | ||
39 | if music is not None: | ||
40 | music.wait_event.set() | ||