3 import sys, os, string, socket, time
4 from popen2 import popen2
5 from pyPgSQL import PgSQL
6 from LATClient import LATClient
9 def __init__(self, rfh, wfh):
15 def await_prompt(self):
21 if s == '': raise Exception
22 if s == '\n' and state == 0: state = 1
23 if s == '#' and state == 1: state = 2
24 if s == ' ' and state == 2: state = 3
26 def get_response(self):
30 s = self.rfh.readline()
31 if s == '': return None
36 self.wfh.write('PING\n')
37 return self.get_response()
39 if __name__ == '__main__':
40 # Open vending machine via LAT
41 latclient = LATClient(service = 'VEND', password = 'dmscptd')
42 (rfh, wfh) = latclient.get_fh()
43 v = VendingMachine(rfh, wfh)