I have the following method:
def PopulateStaticDetails(args):
confParser = ConfigParser.SafeConfigParser()
confParser.read(args.configFile)
generator = ''
emails = ''
certType = ''
# ---- Cert Server Check ---- #
if args.generator is None:
try: generator = confParser.get('Certificate Generator', 'server').strip()
except:
log.fatal('No certificate generator server designated. Please check your configuration.')
log.fatal('Exiting.')
exit(1)
else:
generator = args.generator
# ---- Cert Type Check ---- #
if args.certType is None:
try: certType = configParser.get('Application Settings', 'cert').strip()
except:
print "Unexpected error:", sys.exc_info()[0]
log.fatal('No certificate type was designated. Please check your configuration.')
exit(1)
else:
certType = args.certType
if certType not in ('2011', '2013', '2015'):
log.fatal('Invalid certificate type: {}'.format(certType))
exit(1)
# ---- Email List Check ---- #
if args.emails is None:
try:
emails = confParser.get('Application Settings', 'emails').strip().split('\n')
if emails == ['']: raise
except:
log.warn('No email address specified to send results to.')
else:
emails = args.emails
destDir = '{}/{}'.format(args.destdir,certType)
certPass = getpass.getpass(prompt="Enter your password for access before proceeding:\n")
return StaticDetails(generator, args.certuser, certType, certPass, emails, destDir)
With the following config:
[Application Settings]
servers:
serv.a.com
serv.b.com
serv.c.com
cert: 2015
emails: me@supbro.com
I get the following output though:
Unexpected error: <type 'exceptions.NameError'>
[2015-04-09 17:43:33,911] | ssl-setup - CRITICAL - No certificate type was designated. Please check your configuration.
If I specify it on the command-line, --cert 2015
, it continues successfully. Why does the emails:
section work fine, but the cert:
section doesn't? I'm sure there's something simple here that I've just overlooked ...