Python config parser raises exception for one value but not others -


i have following method:

def populatestaticdetails(args):     confparser = configparser.safeconfigparser()     confparser.read(args.configfile)      generator = ''     emails = ''     certtype = ''      # ---- cert server check ---- #     if args.generator none:         try: generator = confparser.get('certificate generator', 'server').strip()         except:             log.fatal('no certificate generator server designated. please check configuration.')             log.fatal('exiting.')             exit(1)     else:         generator = args.generator      # ---- cert type check ---- #     if args.certtype none:         try: certtype = configparser.get('application settings', 'cert').strip()         except:             print "unexpected error:", sys.exc_info()[0]             log.fatal('no certificate type designated. please check 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 none:         try:             emails = confparser.get('application settings', 'emails').strip().split('\n')             if emails == ['']: raise         except:             log.warn('no email address specified send results to.')     else:         emails = args.emails      destdir = '{}/{}'.format(args.destdir,certtype)     certpass = getpass.getpass(prompt="enter password access  before proceeding:\n")     return staticdetails(generator, args.certuser, certtype, certpass, emails, destdir) 

with following config:

[application settings] servers:     serv.a.com     serv.b.com     serv.c.com  cert: 2015  emails: me@supbro.com 

i following output though:

unexpected error: <type 'exceptions.nameerror'> [2015-04-09 17:43:33,911] | ssl-setup - critical - no certificate type designated. please check configuration. 

if specify on command-line, --cert 2015, continues successfully. why emails: section work fine, cert: section doesn't? i'm sure there's simple here i've overlooked ...


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -