Code

Fix for config file reading
authorSven Velt <sven@velt.de>
Fri, 3 Sep 2010 13:53:04 +0000 (15:53 +0200)
committerSven Velt <sven@velt.de>
Fri, 3 Sep 2010 13:53:04 +0000 (15:53 +0200)
nagixsc_conf2http.py
nagixsc_http2nagios.py

index c87959bde20de2e135e1eff24b6dea8e5b3ad25b..7698d43a18cfb8811a300ecf730850e69cfe9010 100755 (executable)
@@ -46,10 +46,10 @@ config = {
                        'pidfile': '/var/run/nagixsc_conf2http.pid'
                }
 
-if 'ip' in cfgread.items('server'):
+if 'ip' in cfgread.options('server'):
        config['ip'] = cfgread.get('server', 'ip')
 
-if 'port' in cfgread.items('server'):
+if 'port' in cfgread.options('server'):
        config['port'] = cfgread.get('server', 'port')
 try:
        config['port'] = int(config['port'])
@@ -57,7 +57,7 @@ except ValueError:
        print 'Port "%s" not an integer!' % config['port']
        sys.exit(127)
 
-if 'ssl' in cfgread.items('server'):
+if 'ssl' in cfgread.options('server'):
        try:
                config['ssl'] = cfgread.getboolean('server', 'ssl')
        except ValueError:
@@ -65,7 +65,7 @@ if 'ssl' in cfgread.items('server'):
                sys.exit(127)
 
 if config['ssl']:
-       if 'sslcert' in cfgread.items('server'):
+       if 'sslcert' in cfgread.options('server'):
                config['sslcert'] = cfgread.get('server', 'sslcert')
        else:
                print 'SSL but no certificate file specified!'
@@ -77,7 +77,7 @@ except ConfigParser.NoOptionError:
        print 'No "conf_dir" specified!'
        sys.exit(127)
 
-if 'pidfile' in cfgread.items('server'):
+if 'pidfile' in cfgread.options('server'):
        config['pidfile'] = cfgread.get('server', 'pidfile')
 
 
index dd05e62e90c554559cf0b0144c94bfa94ccd6635..df8e2d394f7fd47de91c327f815905c9c5e216d5 100755 (executable)
@@ -46,10 +46,10 @@ config = {
                        'pidfile': '/var/run/nagixsc_conf2http.pid'
                }
 
-if 'ip' in cfgread.items('server'):
+if 'ip' in cfgread.options('server'):
        config['ip'] = cfgread.get('server', 'ip')
 
-if 'port' in cfgread.items('server'):
+if 'port' in cfgread.options('server'):
        config['port'] = cfgread.get('server', 'port')
 try:
        config['port'] = int(config['port'])
@@ -57,7 +57,7 @@ except ValueError:
        print 'Port "%s" not an integer!' % config['port']
        sys.exit(127)
 
-if 'ssl' in cfgread.items('server'):
+if 'ssl' in cfgread.options('server'):
        try:
                config['ssl'] = cfgread.getboolean('server', 'ssl')
        except ValueError:
@@ -65,7 +65,7 @@ if 'ssl' in cfgread.items('server'):
                sys.exit(127)
 
 if config['ssl']:
-       if 'sslcert' in cfgread.items('server'):
+       if 'sslcert' in cfgread.options('server'):
                config['sslcert'] = cfgread.get('server', 'sslcert')
        else:
                print 'SSL but no certificate file specified!'