2 import subprocess, curses
4 class TimeMachine(Views.View):
6 def __init__(self, context, name, x, y, dx, dy, ports, dir, buffer):
7 Views.View.__init__(self, context, name, x, y, dx, dy)
8 nul = file("/dev/null","w")
9 self._tm = subprocess.Popen(["timemachine", "-i", "-t", str(buffer)] + list(ports), cwd=dir,
10 stdin=subprocess.PIPE, stdout=nul, stderr=nul)
11 self._recording = False
14 if not self._recording:
15 self._tm.stdin.write("start\n")
16 self._recording = True
21 self._tm.stdin.write("stop\n")
22 self._recording = False
31 def _redraw(self, refresh=True):
32 self.win().addstr(1,2,"Status: ")
34 self.win().addstr(1,10, "RECORDING", curses.A_BOLD)
36 self.win().addstr(1,10, "Idle ")
40 def updateView(self, bindings):
47 class ToggleRecord(Actions.Action):
49 def __init__(self, name, tm):
50 Actions.Action.__init__(self, name)
53 def __call__(self, binding):
57 def register(viewmanager, context, name, x, y, dx, dy, ports, dir, buffer):
58 tm = TimeMachine(context, name, x, y, dx, dy, ports, dir, buffer)
59 viewmanager.registerView(tm)