1 # Copyright (C) 2010-2012 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 under the
6 # terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option) any
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with Hooke. If not, see <http://www.gnu.org/licenses/>.
21 >>> from hooke.command_stack import CommandStack
22 >>> from hooke.engine import CommandMessage
23 >>> from hooke.hooke import Hooke
26 Setup logging so we can check command output in the doctest.
28 >>> log = logging.getLogger('hooke')
29 >>> stdout_handler = logging.StreamHandler(sys.stdout)
30 >>> log.addHandler(stdout_handler)
32 Setup a playlist to act on.
34 >>> h.run_command('load playlist',
35 ... {'input': 'test/data/vclamp_picoforce/playlist'}) # doctest: +ELLIPSIS
36 engine running internal <CommandMessage load playlist {input: test/data/vclamp_picoforce/playlist}>
37 engine message from load playlist (<class 'hooke.playlist.FilePlaylist'>): <FilePlaylist ...>
38 engine message from load playlist (<class 'hooke.command.Success'>):
39 >>> stack = CommandStack([
40 ... CommandMessage('get curve'),
41 ... CommandMessage('zero surface contact point'),
44 Test `apply command stack to playlist`.
46 >>> h.run_command('apply command stack to playlist',
47 ... {'commands': stack, 'evaluate': True}) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE, +REPORT_UDIFF
48 engine running internal <CommandMessage apply command stack to playlist
49 {commands: [<CommandMessage get curve>,
50 <CommandMessage zero surface contact point>],
52 loading curve 20071120a_i27_t33.100 with driver ...
53 engine running internal <CommandMessage execute command stack {...}>
54 engine running internal <CommandMessage get curve {stack: True}>
55 engine message from get curve (<class 'hooke.curve.Curve'>): <Curve 20071120a_i27_t33.100>
56 engine message from get curve (<class 'hooke.command.Success'>):
57 engine running internal <CommandMessage zero surface contact point {...}>
58 engine message from zero surface contact point (<type 'dict'>): {...}
59 engine message from zero surface contact point (<class 'hooke.command.Success'>):
60 engine message from execute command stack (<class 'hooke.command.Success'>):
61 loading curve 20071120a_i27_t33.101 with driver ...
62 engine running internal <CommandMessage execute command stack {...}>
63 engine running internal <CommandMessage get curve {stack: True}>
64 engine message from get curve (<class 'hooke.curve.Curve'>): <Curve 20071120a_i27_t33.101>
65 engine message from get curve (<class 'hooke.command.Success'>):
66 engine running internal <CommandMessage zero surface contact point {...}>
67 engine message from zero surface contact point (<type 'dict'>): {...}
68 engine message from zero surface contact point (<class 'hooke.command.Success'>):
69 engine message from execute command stack (<class 'hooke.command.Success'>):
70 loading curve 20071120a_i27_t33.102 with driver ...
73 loading curve 20071120a_i27_t33.199 with driver ...
74 engine running internal <CommandMessage execute command stack {...}>
75 engine running internal <CommandMessage get curve {stack: True}>
76 engine message from get curve (<class 'hooke.curve.Curve'>): <Curve 20071120a_i27_t33.199>
77 engine message from get curve (<class 'hooke.command.Success'>):
78 engine running internal <CommandMessage zero surface contact point {...}>
79 engine message from zero surface contact point (<type 'dict'>): {...}
80 engine message from zero surface contact point (<class 'hooke.command.Success'>):
81 engine message from execute command stack (<class 'hooke.command.Success'>):
82 loading curve 0x06130001 with driver ...
83 unloading curve 20071120a_i27_t33.100
84 engine running internal <CommandMessage execute command stack
85 {commands: [<CommandMessage get curve>,
86 <CommandMessage zero surface contact point>],
88 engine running internal <CommandMessage get curve {stack: True}>
90 engine message from apply command stack to playlist (<class 'hooke.command.Success'>):
91 >>> curve = h.playlists.current().current(
92 ... ) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
93 loading curve 20071120a_i27_t33.100 with driver ...
94 engine running internal <CommandMessage zero surface contact point
95 {block: None, curve: <Curve 20071120a_i27_t33.100>, ...}>
96 engine message from zero surface contact point (<type 'dict'>): {...}
97 engine message from zero surface contact point (<class 'hooke.command.Success'>):
98 unloading curve 20071120a_i27_t33.102
100 <Curve 20071120a_i27_t33.100>
101 >>> curve.command_stack # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
102 [<CommandMessage zero surface contact point
103 {block: None, curve: <Curve 20071120a_i27_t33.100>, ...}>]
105 Test `apply command stack to playlist` without evaluating.
107 >>> stack = CommandStack([
108 ... CommandMessage('flat filter peaks',
109 ... {'block':'retract', 'min points':1}),
111 >>> h.run_command('apply command stack to playlist',
112 ... {'commands': stack, 'evaluate': False}
113 ... ) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE, +REPORT_UDIFF
114 engine running internal
115 <CommandMessage apply command stack to playlist {...}>
116 unloading curve 20071120a_i27_t33.100
117 unloading curve 20071120a_i27_t33.101
118 unloading curve 20071120a_i27_t33.102
120 unloading curve 20071120a_i27_t33.199
121 unloading curve 0x06130001
122 unloading curve 0x07200000
123 engine message from apply command stack to playlist
124 (<class 'hooke.command.Success'>):
125 >>> for c in curve.command_stack:
126 ... print c # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE, +REPORT_UDIFF
127 <CommandMessage zero surface contact point
128 {..., curve: <Curve 20071120a_i27_t33.100>...}>
129 <CommandMessage flat filter peaks {block: retract, min points: 1}>
131 Test `clear curve command stack`.
133 >>> h.run_command('clear curve command stack', arguments={})
134 engine running internal <CommandMessage clear curve command stack>
135 engine message from clear curve command stack (<class 'hooke.command.Success'>):
136 >>> curve.command_stack