import socket
from posix import geteuid
from LDAPConnector import get_uid,get_uname, set_card_id
+from OpenDispense import OpenDispense as Dispense
CREDITS="""
This vending machine software brought to you by:
TEXT_SPEED = 0.8
IDLE_SPEED = 0.05
+_pin_uid = 0
+_pin_uname = 'root'
+_pin_pin = '----'
+
+_last_card_id = -1
+
+idlers = []
+idler = None
+
+
class DispenseDatabaseException(Exception): pass
class DispenseDatabase:
self.process_requests()
notify = self.db.getnotify()
+class VendState:
+ def __init__(self,v):
+ self.state_table = {}
+ self.state = STATE_IDLE
+ self.counter = 0
+
+ self.mk = MessageKeeper(v)
+ self.cur_user = ''
+ self.cur_pin = ''
+ self.username = ''
+ self.cur_selection = ''
+ self.time_to_autologout = None
+
+ self.last_timeout_refresh = None
+
+ def change_state(self,newstate,newcounter=None):
+ if self.state != newstate:
+ #print "Changing state from: ",
+ #print self.state,
+ #print " to ",
+ #print newstate
+ self.state = newstate
+
+ if newcounter is not None and self.counter != newcounter:
+ #print "Changing counter from: ",
+ #print self.counter,
+ #print " to ",
+ #print newcounter
+ self.counter = newcounter
+
+
+
def scroll_options(username, mk, welcome = False):
if welcome:
# Balance checking
msg.append((choices, False, None))
mk.set_messages(msg)
-_pin_uid = 0
-_pin_uname = 'root'
-_pin_pin = '----'
-
def _check_pin(uid, pin):
global _pin_uid
global _pin_uname
LEN = 10
return ' '*((LEN-len(str))/2)+str
-
-
-idlers = []
-idler = None
-
def setup_idlers(v):
global idlers, idler
idlers = [
nextidle = IDLE_SPEED
vstatus.time_of_next_idlestep = time()+nextidle
-class VendState:
- def __init__(self,v):
- self.state_table = {}
- self.state = STATE_IDLE
- self.counter = 0
-
- self.mk = MessageKeeper(v)
- self.cur_user = ''
- self.cur_pin = ''
- self.username = ''
- self.cur_selection = ''
- self.time_to_autologout = None
-
- self.last_timeout_refresh = None
-
- def change_state(self,newstate,newcounter=None):
- if self.state != newstate:
- #print "Changing state from: ",
- #print self.state,
- #print " to ",
- #print newstate
- self.state = newstate
-
- if newcounter is not None and self.counter != newcounter:
- #print "Changing counter from: ",
- #print self.counter,
- #print " to ",
- #print newcounter
- self.counter = newcounter
-
def handle_tick_event(event, params, v, vstatus):
logging.warning('Leaving open door mode')
v.display("-YUM YUM!-")
-_last_card_id = -1
def handle_mifare_event(state, event, params, v, vstatus):
global _last_card_id