Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import osc, log
class Action:
def __init__(self, text, **kwargs):
self.text = text
for key, value in kwargs:
setattr(self, key, value)
class ActionManager:
def __init__(self, host, port, confirmer, highlighter, logger=log.ConsoleLogger()):
#self.client = osc.Client(host, port)
self.confirmer = confirmer
self.highlighter = highlighter
self.logger = logger
def confirmed_perform(self, action):
osc.client.send_action(action)
self.highlighter.highlight(action)
self.logger.log(action)
def perform(self, action, confirm=True, timeout=3):
if confirm:
self.confirmer.confirm('Perform action "%s"?' % action.text, time, lambda: self.confirmed_perform(action))
else:
self.confirmed_perform(action)
manager = None
def setup(confirmer, highlighter, logger):
global manager
manager = ActionManager(confirmer, highlighter, logger)
def perform_action(action, confirm=True, timeout=3):
global manager
manager.perform(action, confirm, timeout)