X-Git-Url: https://git.ucc.asn.au/?p=uccvend-vendserver.git;a=blobdiff_plain;f=sql-edition%2Fservers%2FVendServer.py;h=6b24f80ab0754c16ba9b6619840c7dc7aa71d6ad;hp=f68cf1a93bfafa272e9ebf530caf08b84e6a514f;hb=15bf186b639b1ee317eb780c7a85fd2a1de50efe;hpb=f999ec660c14d546a1cd6e25c4bef5bdfe5d6dc7;ds=sidebyside diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index f68cf1a..6b24f80 100755 --- a/sql-edition/servers/VendServer.py +++ b/sql-edition/servers/VendServer.py @@ -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)) @@ -938,7 +941,7 @@ def parse_args(): from optparse import OptionParser op = OptionParser(usage="%prog [OPTION]...") - op.add_option('-f', '--config-file', default='/etc/dispense/servers.conf', metavar='FILE', dest='config_file', help='use the specified config file instead of /etc/dispense/servers.conf') + op.add_option('-f', '--config-file', default='/etc/dispense2/servers.conf', metavar='FILE', dest='config_file', help='use the specified config file instead of /etc/dispense/servers.conf') op.add_option('--serial', action='store_true', default=True, dest='use_serial', help='use the serial port') op.add_option('--lat', action='store_true', default=False, dest='use_lat', help='use LAT') op.add_option('--virtualvend', action='store_false', default=True, dest='use_serial', help='use the virtual vending server instead of LAT')