def done(self):
return len(self.scrolling_message) == 0
+idlers = []
+idler = None
+def setup_idlers(v):
+ global idlers, idler
+ idlers = [
+ TrainIdler(v),
+ GrayIdler(v),
+ GrayIdler(v,one="*",zero="-"),
+ GrayIdler(v,one="/",zero="\\"),
+ GrayIdler(v,one="X",zero="O"),
+ ]
+ idler = choose_idler()
+
+def choose_idler():
+ global idler
+ idler = idlers[int(random()*len(idlers))]
+ idler.reset()
+
+def idle_step():
+ global idler
+ idler.next()
+
def run_forever(rfh, wfh, options, cf):
v = VendingMachine(rfh, wfh)
logging.debug('PING is ' + str(v.ping()))
mk = MessageKeeper(v)
mk.set_message(GREETING)
time_to_autologout = None
- #idler = TrainIdler(v)
- #idler = GrayIdler(v)
- idler = GrayIdler(v,one="*",zero="-")
+ setup_idlers(v)
time_to_idle = None
last_timeout_refresh = None
# start autologout
time_to_autologout = time() + 15
- if time_to_idle == None and cur_user == '': time_to_idle = time() + 60
+ if time_to_idle == None and cur_user == '':
+ time_to_idle = time() + 2
+ choose_idler()
if time_to_idle != None and cur_user != '': time_to_idle = None
- if time_to_idle is not None and time() > time_to_idle: idler.next()
+ if time_to_idle is not None and time() > time_to_idle: idle_step()
mk.update_display()
e = v.next_event(0)
if e == None:
- e = v.next_event(0.1)
+ e = v.next_event(0.05)
if e == None:
continue
time_to_idle = None
clean_up_nicely(options, config_opts)
logging.warning("Vend Server stopped")
break
+ except SystemExit:
+ break
except:
(exc_type, exc_value, exc_traceback) = sys.exc_info()
tb = format_tb(exc_traceback, 20)