return rfh, wfh
if __name__ == '__main__':
- from ConfigParser import ConfigParser
+ import ConfigParser
from optparse import OptionParser
op = OptionParser(usage="%prog [OPTION]...")
if len(args) != 0:
op.error('extra command line arguments: ' + ' '.join(args))
- cp = ConfigParser()
- cp.read(options.config_file)
- DBServer = cp.get('Database', 'Server')
- DBName = cp.get('Database', 'Name')
- DBUser = cp.get('VendingMachine', 'DBUser')
- DBPassword = cp.get('VendingMachine', 'DBPassword')
-
- ServiceName = cp.get('VendingMachine', 'ServiceName')
- ServicePassword = cp.get('VendingMachine', 'Password')
-
- ServerName = cp.get('DecServer', 'Name')
- ConnectPassword = cp.get('DecServer', 'ConnectPassword')
- PrivPassword = cp.get('DecServer', 'PrivPassword')
+ try:
+ cp = ConfigParser.ConfigParser()
+ cp.read(options.config_file)
+ DBServer = cp.get('Database', 'Server')
+ DBName = cp.get('Database', 'Name')
+ DBUser = cp.get('VendingMachine', 'DBUser')
+ DBPassword = cp.get('VendingMachine', 'DBPassword')
+
+ ServiceName = cp.get('VendingMachine', 'ServiceName')
+ ServicePassword = cp.get('VendingMachine', 'Password')
+
+ ServerName = cp.get('DecServer', 'Name')
+ ConnectPassword = cp.get('DecServer', 'ConnectPassword')
+ PrivPassword = cp.get('DecServer', 'PrivPassword')
+ except ConfigParser.Error, e:
+ print "Error reading config file: " + str(e)
+ sys.exit(1)
while True:
try: