except socket.error:
raise VendingException('failed to read input from vending machine')
if s == '': raise VendingException('nothing read!')
+ if (s != '#' and s != '%') and state == 1: prefix += s
if s == '\n' or s == '\r':
state = 1
prefix = ''
def vend(self, item):
if not re.search('^[0-9][0-9]$', item):
return (False, 'Invalid item requested (%s)'%item)
- self.wfh.write(self.authed_message(('V%s\n'%item)+'\n'))
+ self.wfh.write(self.authed_message(('V%s'%item))+'\n')
(code, string) = self.get_response()
return (code == '100', code, string)