X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=VendServer%2FVendServer.py;h=f7bc9927048c02a3a9464b1aeab3bf3ef3d52900;hb=50ed02d24589bb4340802826f11125f5e5c9038a;hp=6dfbfe15ea31372ccf1f69a9c01d7bd4e913404d;hpb=8cda0f578277ed1c4ce70c712d2e54311dd79e70;p=uccvend-vendserver.git diff --git a/VendServer/VendServer.py b/VendServer/VendServer.py index 6dfbfe1..f7bc992 100755 --- a/VendServer/VendServer.py +++ b/VendServer/VendServer.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# vim:ts=4 +# vim: ts=4 sts=4 sw=4 noexpandtab USE_MIFARE = 1 @@ -140,6 +140,7 @@ class VendServer(): # If the user has just logged in, show them their balance if welcome: balance = self.dispense.getBalance() + balance = balance[:-4] + '.' + balance[-4] + balance[-2:] # Work around display bug msg = [(self.center('WELCOME'), False, TEXT_SPEED), (self.center(self.dispense.getUsername()), False, TEXT_SPEED), @@ -369,7 +370,7 @@ class VendServer(): self.vstatus.cur_pin = '' self.vstatus.cur_user = '' self.vstatus.cur_selection = '' - _last_card_id = -1 + self._last_card_id = -1 self.vstatus.mk.set_messages([(self.center('BYE!'), False, 1.5)]) self.reset_idler(2) return @@ -391,7 +392,11 @@ class VendServer(): self.vstatus.last_timeout_refresh = None else: # Price check mode. - self.dispense.getItemInfo(self.vstatus.cur_selection) + (name,price) = self.dispense.getItemInfo(self.vstatus.cur_selection) + dollarprice = "$%.2f" % ( price / 100.0 ) + dollarprice = dollarprice[:-4] + '.' + dollarprice[-4] + dollarprice[-2:] # Work around display bug + self.v.display( self.vstatus.cur_selection+' - %s'%dollarprice) + self.vstatus.cur_selection = '' self.vstatus.time_to_autologout = None self.vstatus.last_timeout_refresh = None @@ -400,6 +405,7 @@ class VendServer(): Triggered when the user has entered the id of something they would like to purchase. """ def make_selection(self): + logging.debug('Dispense item "%s"' % (self.vstatus.cur_selection,)) # should use sudo here if self.vstatus.cur_selection == '55': self.vstatus.mk.set_message('OPENSESAME') @@ -476,6 +482,7 @@ class VendServer(): if len(self.vstatus.cur_pin) == PIN_LENGTH: self.dispense.authUserIdPin(self.vstatus.cur_user, self.vstatus.cur_pin) if self.dispense.getUsername(): + self.vstatus.username = self.dispense.getUsername() self.v.beep(0, False) self.vstatus.cur_selection = '' self.vstatus.change_state(STATE_GET_SELECTION) @@ -797,6 +804,8 @@ class VendServer(): self.reset_idler(2) return else: + self.vstatus.cur_user = '----' + self.vstatus.username = self.dispense.getUsername() self.vstatus.cur_selection = '' self.vstatus.change_state(STATE_GET_SELECTION) self.scroll_options(self.vstatus.username, self.vstatus.mk, True)