From 1e053dbf00f7fa8dc8ecfb50f3f9401879cbdd3a Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Tue, 18 Apr 2006 06:44:43 +0000 Subject: [PATCH] use "give oday $price" so we can prune dispense --- sql-edition/servers/VendServer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index 365f9d4..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 @@ -403,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: @@ -416,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) -- 2.20.1