Update for new dispense binary/syntax by [MRD]/[BOB]/[TPG]
authorDavid Adam <zanchey@ucc.gu.uwa.edu.au>
Sat, 9 Apr 2011 03:31:49 +0000 (03:31 +0000)
committerDavid Adam <zanchey@ucc.gu.uwa.edu.au>
Sat, 9 Apr 2011 03:31:49 +0000 (03:31 +0000)
sql-edition/servers/VendServer.py

index f68cf1a..9da6648 100755 (executable)
@@ -94,10 +94,13 @@ class DispenseDatabase:
 
 def scroll_options(username, mk, welcome = False):
        if welcome:
-           # Balance checking: crap code, [DAA]'s fault
-           acct = os.popen('dispense acct %s' % username)
-               balance = acct.read()[15:22]
-               acct.close()
+               # Balance checking: crap code, [DAA]'s fault
+               # Updated 2011 to handle new dispense [MRD]
+               raw_acct = os.popen('dispense acct %s' % username)
+               acct = raw_acct.read()
+               # this is fucking appalling
+               balance = acct[acct.find("$")+1:acct.find("(")].strip()
+               raw_acct.close()
         
                msg = [(center('WELCOME'), False, TEXT_SPEED),
                           (center(username), False, TEXT_SPEED),
@@ -437,7 +440,7 @@ def make_selection(v, vstatus):
                        price, shortname, name = get_snack( '--' )
                dollarprice = "$%.2f" % ( price / 100.0 )
                v.display(vstatus.cur_selection+' - %s'%dollarprice)
-               exitcode = os.system('su - "%s" -c "dispense give oday %d"'%(vstatus.username, price)) >> 8
+               exitcode = os.system('su - "%s" -c "dispense give \>snacksales %d \'%s\'"'%(vstatus.username, price, name)) >> 8
                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))

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