Allow disuse of DB
authorBernard Blackham <[email protected]>
Sun, 27 Jun 2004 18:35:30 +0000 (18:35 +0000)
committerBernard Blackham <[email protected]>
Sun, 27 Jun 2004 18:35:30 +0000 (18:35 +0000)
sql-edition/servers/VendServer.py

index 819de13..b173d3c 100755 (executable)
@@ -1,8 +1,10 @@
 #!/usr/bin/python
 # vim:ts=4
 
+USE_DB = 0
+
 import sys, os, string, re, pwd
-import pg
+if USE_DB: import pg
 from time import time, sleep
 from popen2 import popen2
 from LATClient import LATClient
@@ -186,7 +188,7 @@ if __name__ == '__main__':
        v = VendingMachine(rfh, wfh)
        print 'PING is', v.ping()
 
-       db = DispenseDatabase(v, DBServer, DBName, DBUser, DBPassword)
+       if USE_DB: db = DispenseDatabase(v, DBServer, DBName, DBUser, DBPassword)
        cur_user = ''
        cur_pin = ''
        cur_selection = ''
@@ -197,11 +199,11 @@ if __name__ == '__main__':
        last_timeout_refresh = None
 
        while True:
-               db.handle_events()
+               if USE_DB: db.handle_events()
 
                if logout_timeout != None:
                        time_left = logout_timeout - time()
-                       if time_left < 10 and (last_timeout_refresh > time_left or last_timeout_refresh is None):
+                       if time_left < 10 and (last_timeout_refresh is None or last_timeout_refresh > time_left):
                                mk.set_message('LOGOUT: '+str(int(time_left)))
                                last_timeout_refresh = int(time_left)
 

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