1 # Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
3 # This file is part of Hooke.
5 # Hooke is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 # Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with Hooke. If not, see
17 # <http://www.gnu.org/licenses/>.
20 >>> from hooke.hooke import Hooke, HookeRunner
24 The command stack starts off empty.
26 >>> h = r.run_lines(h, ['get_command_stack'])
31 And inactive, so you can't stop it.
33 >>> h = r.run_lines(h, ['get_command_capture_state'])
37 >>> h = r.run_lines(h, ['stop_command_capture'])
39 invalid state change: inactive -> inactive
41 Because :meth:`hooke.hooke.HookeRunner.run_lines` spawns and closes
42 its own engine subprocess, we need to run the whole capture session in
43 a single call. The command stack, on the other hand, will be
44 preserved between calls.
46 You can't restart recording.
48 >>> h = r.run_lines(h, ['start_command_capture',
49 ... 'get_command_capture_state',
50 ... 'start_command_capture',
51 ... 'restart_command_capture']) # doctest: +REPORT_UDIFF
58 invalid state change: active -> active
60 invalid state change: active -> active
62 But you can stop and restart.
64 >>> h = r.run_lines(h, ['start_command_capture',
65 ... 'stop_command_capture',
66 ... 'restart_command_capture']) # doctest: +REPORT_UDIFF
74 Lets add some commands to the stack.
76 >>> h = r.run_lines(h, ['start_command_capture',
77 ... 'load_playlist test/data/test',
79 ... 'stop_command_capture']) # doctest: +REPORT_UDIFF
88 >>> h = r.run_lines(h, ['get_command_stack']) # doctest: +NORMALIZE_WHITESPACE
89 [<CommandMessage load playlist {input: test/data/test}>,
90 <CommandMessage get curve>]
94 When capture is stopped, command execution is normal.
96 >>> h = r.run_lines(h, ['restart_command_capture',
98 ... 'stop_command_capture',
100 ... 'restart_command_capture',
101 ... 'previous_curve',
102 ... 'stop_command_capture']
103 ... ) # doctest: +ELLIPSIS, +REPORT_UDIFF
110 Hooke 1.0.0.alpha (Ninken)
119 You can pop commands regardless of the recording state.
121 >>> h = r.run_lines(h, ['pop_command_from_stack'])
122 <CommandMessage previous curve>
125 >>> h = r.run_lines(h, ['get_command_stack']) # doctest: +NORMALIZE_WHITESPACE
126 [<CommandMessage load playlist {input: test/data/test}>,
127 <CommandMessage get curve>,
128 <CommandMessage curve info>]
132 >>> h = r.run_lines(h, ['restart_command_capture',
133 ... 'pop_command_from_stack',
134 ... 'get_command_stack',
135 ... 'stop_command_capture']
136 ... ) # doctest: +NORMALIZE_WHITESPACE, +REPORT_UDIFF
139 <CommandMessage curve info>
142 [<CommandMessage load playlist {input: test/data/test}>,
143 <CommandMessage get curve>]
149 If you start up again (using `start` not `restart`), the stack is cleared.
151 >>> h = r.run_lines(h, ['start_command_capture',
152 ... 'stop_command_capture'])
157 >>> h = r.run_lines(h, ['get_command_stack'])