46
46
#Change this value to modify polling rate. Currently 100 ms
47
47
POLL_RATE = 0.1
48
48
49
+ #pylint: disable-msg=R0902
49
50
50
51
class Host (object ):
51
52
"""
@@ -178,18 +179,22 @@ def _serial_runner(self, portname):
178
179
179
180
# With the exception of Stacked and Returned, only we can
180
181
# only be in one state at once
181
- status = Host .state_dict [ord (out [3 ])]
182
+ try :
183
+ status = Host .state_dict [ord (out [3 ])]
184
+ except KeyError :
185
+ print "unknown state dic key {:d}" .format (ord (out [3 ]))
186
+
182
187
self .escrowed = ord (out [3 ]) & 4
183
- if ord (out [3 ]) & 0x10 :
184
- status += " STACKED "
185
- if ord (out [3 ]) & 0x40 :
186
- status += " RETURNED "
187
188
188
189
# If there is no match, we get an empty string
189
- status += Host .event_dict [ord (out [4 ]) & 1 ]
190
- status += Host .event_dict [ord (out [4 ]) & 2 ]
191
- status += Host .event_dict [ord (out [4 ]) & 4 ]
192
- status += Host .event_dict [ord (out [4 ]) & 8 ]
190
+ try :
191
+ status += Host .event_dict [ord (out [4 ]) & 1 ]
192
+ status += Host .event_dict [ord (out [4 ]) & 2 ]
193
+ status += Host .event_dict [ord (out [4 ]) & 4 ]
194
+ status += Host .event_dict [ord (out [4 ]) & 8 ]
195
+ except KeyError :
196
+ print "unknown state dic key {:d}" .format (ord (out [4 ]))
197
+
193
198
if ord (out [4 ]) & 0x10 != 0x10 :
194
199
status += " CASSETTE MISSING"
195
200
@@ -208,7 +213,8 @@ def _serial_runner(self, portname):
208
213
if ord (out [3 ]) & 0x10 :
209
214
print "Bill credited: Bill#" , credit
210
215
self .bill_count [credit ] += 1
211
- print "Acceptor now holds:" , binascii .hexlify (self .bill_count )
216
+ print "Acceptor now holds: {:s}" .format (
217
+ binascii .hexlify (self .bill_count ))
212
218
213
219
time .sleep (POLL_RATE )
214
220
0 commit comments