Fix autologout bug
[zanchey/dispense2.git] / sql-edition / servers / VendServer.py
index c93fda0..365f9d4 100755 (executable)
@@ -17,6 +17,7 @@ from MessageKeeper import MessageKeeper
 from HorizScroll import HorizScroll
 from random import random, seed
 from Idler import GreetingIdler,TrainIdler,GrayIdler,StringIdler,ClockIdler,FortuneIdler,FileIdler,PipeIdler
+from SnackConfig import get_snacks, get_snack
 import socket
 from posix import geteuid
 
@@ -104,9 +105,20 @@ def scroll_options(username, mk, welcome = False):
                c = c.strip()
                (slot_num, price, slot_name) = c.split(' ', 2)
                if slot_name == 'dead': continue
-               choices += '%s8-%s (%sc) '%(slot_num, slot_name, price)
+               choices += '%s-(%sc)-%s8 '%(slot_name, price, slot_num)
+
+#      we don't want to print snacks for now since it'll be too large
+#      and there's physical bits of paper in the machine anyway - matt
+#      try:
+#              snacks = get_snacks()
+#      except:
+#              snacks = {}
+#
+#      for slot, ( name, price ) in snacks.items():
+#              choices += '%s8-%s (%sc) ' % ( slot, name, price )
+
        choices += '55-DOOR '
-       choices += 'OR A SNACK. '
+       choices += 'OR ANOTHER SNACK. '
        choices += '99 TO READ AGAIN. '
        choices += 'CHOICE?   '
        msg.append((choices, False, None))
@@ -203,7 +215,7 @@ def setup_idlers(v):
                 GrayIdler(v,one="/",zero="\\",reorder=1),
                StringIdler(v, text=str(math.e) + "            "),
                 GrayIdler(v,one="X",zero="O",reorder=1),
-               StringIdler(v, text="    I want some pizza - please call Pizza Hut Shenton Park on +61 8 9381 9979 - and order as Quinn - I am getting really hungry", repeat=False),
+               StringIdler(v, text="    I want some pizza - please call Pizza Hut Shenton Park on +61 8 9381 9979 [now closed? - MSH] - and order as Quinn - I am getting really hungry", repeat=False),
                PipeIdler(v, "/usr/bin/getent", "passwd"),
                FortuneIdler(v),
                ClockIdler(v),
@@ -218,6 +230,7 @@ def reset_idler(v, vstatus, t = None):
        idler = GreetingIdler(v, t)
        vstatus.time_of_next_idlestep = time()+idler.next()
        vstatus.time_of_next_idler = None
+       vstatus.time_to_autologout = None
        vstatus.change_state(STATE_IDLE, 1)
 
 def choose_idler():
@@ -396,8 +409,14 @@ def make_selection(v, vstatus):
                else:
                        v.display('GOT COKE!')
        else:
-               v.display(vstatus.cur_selection+' - $1.00')
-               if ((os.system('su - "%s" -c "dispense snack"'%(vstatus.username)) >> 8) == 0):
+               # first see if it's a named slot
+               try:
+                       price, shortname, name = get_snack( vstatus.cur_selection )
+               except:
+                       price, shortname, name = get_snack( '--' )
+               dollarprice = "$%.2f" % ( price / 100.0 )
+               v.display(vstatus.cur_selection+' - %s'%dollarprice)
+               if ((os.system('su - "%s" -c "dispense %s"'%(vstatus.username, shortname)) >> 8) == 0):
                        v.vend(vstatus.cur_selection)
                        v.display('THANK YOU')
                else:

UCC git Repository :: git.ucc.asn.au