git.ucc.asn.au
/
uccvend-vendserver.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
VendServer - Set username state on MIFARE auth, clear MIFARE id on logout
[uccvend-vendserver.git]
/
VendServer
/
VendServer.py
diff --git
a/VendServer/VendServer.py
b/VendServer/VendServer.py
index
be8cea0
..
f7bc992
100755
(executable)
--- a/
VendServer/VendServer.py
+++ b/
VendServer/VendServer.py
@@
-1,5
+1,5
@@
#!/usr/bin/python
#!/usr/bin/python
-# vim:
ts=4
+# vim:
ts=4 sts=4 sw=4 noexpandtab
USE_MIFARE = 1
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 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="""
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()
# 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),
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 = ''
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
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.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
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):
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')
# 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():
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)
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.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)
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
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:
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)])
self.vstatus.mk.set_messages(
[(self.center('CARD'), False, 0.5),
(self.center('ENROLLED'), False, 0.5)])
UCC
git Repository :: git.ucc.asn.au