add command-line option for using a different config file
[uccvend-vendserver.git] / sql-edition / servers / VendServer.py
index 19a7e67..125de02 100755 (executable)
@@ -366,6 +366,7 @@ if __name__ == '__main__':
        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('-v', '--virtualvend', action='store_false', default=True, dest='use_lat', help='use the virtual vending server instead of LAT')
        op.add_option('-n', '--hostname', dest='host', default='localhost', help='the hostname to connect to for virtual vending machine mode (default: localhost)')
        op.add_option('-p', '--port', dest='port', default=5150, type='int', help='the port number to connect to (default: 5150)')
@@ -375,7 +376,7 @@ if __name__ == '__main__':
                op.error('extra command line arguments: ' + ' '.join(args))
 
        cp = ConfigParser()
-       cp.read('/etc/dispense/servers.conf')
+       cp.read(options.config_file)
        DBServer = cp.get('Database', 'Server')
        DBName = cp.get('Database', 'Name')
        DBUser = cp.get('VendingMachine', 'DBUser')

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