X-Git-Url: https://git.ucc.asn.au/?p=uccvend-vendserver.git;a=blobdiff_plain;f=sql-edition%2Fservers%2FVendServer.py;h=0b45a40b03a9e36acd3d2ee086561f5511bad6dc;hp=9792c564d868535c7f21b72979dcfab0bea4491f;hb=1e053dbf00f7fa8dc8ecfb50f3f9401879cbdd3a;hpb=b96be3def8c7257967e4e4418189622e07c97ced diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index 9792c56..0b45a40 100755 --- a/sql-edition/servers/VendServer.py +++ b/sql-edition/servers/VendServer.py @@ -4,7 +4,7 @@ USE_DB = 0 import ConfigParser -import sys, os, string, re, pwd, signal, math +import sys, os, string, re, pwd, signal, math, syslog import logging, logging.handlers from traceback import format_tb if USE_DB: import pg @@ -105,7 +105,7 @@ 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 @@ -215,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), @@ -230,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(): @@ -402,11 +403,11 @@ def make_selection(v, vstatus): vstatus.cur_selection = '' return elif vstatus.cur_selection[1] == '8': - v.display('GOT COKE?') + v.display('GOT DRINK?') if ((os.system('su - "%s" -c "dispense %s"'%(vstatus.username, vstatus.cur_selection[0])) >> 8) != 0): v.display('SEEMS NOT') else: - v.display('GOT COKE!') + v.display('GOT DRINK!') else: # first see if it's a named slot try: @@ -415,10 +416,14 @@ def make_selection(v, vstatus): 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): + exitcode = os.system('su - "%s" -c "dispense give oday %d"'%(vstatus.username, price)) + if (exitcode == 0): + # magic dispense syslog service + syslog.syslog(syslog.LOG_INFO | syslog.LOG_LOCAL4, "vended %s (slot %s) for %s" % (name, vstatus.cur_selection, vstatus.username)) v.vend(vstatus.cur_selection) v.display('THANK YOU') else: + syslog.syslog(syslog.LOG_INFO | syslog.LOG_LOCAL4, "failed vending %s (slot %s) for %s, code %d" % (name, vstatus.cur_selection, vstatus.username, exitcode)) v.display('NO MONEY?') sleep(1)