X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=VendServer%2FVendServer.py;h=f7bc9927048c02a3a9464b1aeab3bf3ef3d52900;hb=50ed02d24589bb4340802826f11125f5e5c9038a;hp=be8cea09203e12b3059c8df8c387687bd23fb36e;hpb=c46bfcfa82d48492d05d0c3555aba71b67692762;p=uccvend-vendserver.git diff --git a/VendServer/VendServer.py b/VendServer/VendServer.py index be8cea0..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 @@ -19,7 +19,6 @@ from Idler import GreetingIdler,TrainIdler,GrayIdler,StringIdler,ClockIdler,Fort from SnackConfig import get_snack#, get_snacks import socket from posix import geteuid -from LDAPConnector import get_uid,get_uname, set_card_id from OpenDispense import OpenDispense as Dispense CREDITS=""" @@ -141,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), @@ -370,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 @@ -392,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 @@ -401,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') @@ -477,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) @@ -798,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) @@ -815,15 +823,11 @@ class VendServer(): self._last_card_id = card_id - res = self.dispense.addCard(card_id) - - if get_uid(card_id) != None: + if not self.dispense.addCard(card_id): self.vstatus.mk.set_messages( [(self.center('ALREADY'), False, 0.5), (self.center('ENROLLED'), False, 0.5)]) else: - logging.info('Enrolling card %s to uid %s (%s)'%(card_id, self.vstatus.cur_user, self.vstatus.username)) - self.set_card_id(self.vstatus.cur_user, self.card_id) self.vstatus.mk.set_messages( [(self.center('CARD'), False, 0.5), (self.center('ENROLLED'), False, 0.5)])