def main(args): try: opts, args = getopt.getopt(args, SHORT_SWITCHES, LONG_SWITCHES) optsdict = {} for (opt, val) in opts: optsdict[opt] = val switches = optsdict.keys() except getopt.GetoptError, msg: sys.stderr.write(str(msg) + "\nUse -h for help.\n") sys.exit(1) except: raise resources_filename = RESOURCESFILENAME if (not switches) and (not args): help.helpme(False) sys.exit(1) if ("-h" in switches) or ("--help" in switches): help.helpme(False) sys.exit(0) if ("-v" in switches) or ("--version" in switches): help.version(False) sys.exit(0) if "-o" in switches: rdfdir = optsdict["-o"] else: rdfdir = RDFDIR
except: raise # Setup the configuration and get the mode in which we are supposed to # run. try: mode, args, config = setup(argdict) except ex.setup_error, errmsg: sys.stderr.write('%s\n' % errmsg) sys.exit(2) except: raise # Check for the simpler modes that does not involve the upgrade module. if mode == 'help': help.helpme() sys.exit(0) elif mode == 'version': help.version() sys.exit(0) elif mode == 'copyright': help.copyright() sys.exit(0) elif mode == 'remove_lock': remove_lock(config) sys.exit(0) elif mode == 'import_key': if set_lock(config): try: import_key(args, config['gnupgdir']) remove_lock(config)