3 class VendingException( Exception ): pass
11 return (0, 'nothing', 'Nothing')
12 cmd = 'dispense iteminfo snack:%s' % slot
13 # print 'cmd = %s' % cmd
15 # info = subprocess.check_output(["dispense","iteminfo",'snack:%s'%slot])
19 # print 'cmd (2) = %s' % cmd
20 # print 'info = "%s"' % info
21 m = re.match("\s*[a-z]+:\d+\s+(\d+)\.(\d\d)\s+([^\n]+)", info)
22 val = ( int(m.group(1))*100 + int(m.group(2)), m.group(3), m.group(3) )
23 # print 'Price: %i, Name: %s' % (val[0], val[1])
24 except BaseException as e:
27 val = (0, 'error', 'Error')
29 print "Unknown exception"
30 val = (0, 'error', 'Error')
33 def get_price( slot ):
34 p, sn, n = get_snacks( slot )
38 p, sn, n = get_snacks( slot )
41 def get_short_name( slot ):
42 p, sn, n = get_snacks( slot )
45 if __name__ == '__main__':
46 print "Don't run this"