def main(self, argv=None, debuggerException=Exception, cfg=None,
             debugAll=False, **kw):
        if argv is None:
            argv=sys.argv
        from conary import versions
        supportedCommands = self._supportedCommands

        if '--version' in argv:
            print self.version
            return

        if cfg is None:
            cfg = self.getConfigFile(argv)

        # get the default setting for exception debugging from the
        # config object (if it has a setting).
        debug = getattr(cfg, 'debugExceptions', False)
        if debugAll:
            if hasattr(cfg, 'debugExceptions'):
                cfg.debugExceptions = True
            debug = True
        if self.setSysExcepthook:
            sys.excepthook = util.genExcepthook(debug=debug,
                                                debugCtrlC=debugAll)

        try:
            argSet, argv = self._getPreCommandOptions(argv, cfg)
        except debuggerException:
            raise
        except options.OptionError, e:
            self.usage()
            print >>sys.stderr, e
            sys.exit(e.val)

        thisCommand = self.getCommand(argv, cfg)
        if thisCommand is None:
            return self.usage()
        commandName = argv[1]

        params, cfgMap = thisCommand.prepare()
        kwargs = self._getParserFlags(thisCommand)

        try:
            newArgSet, otherArgs, parser, optionSet = options._processArgs(
                                        params, {}, cfg,
                                        usage=self._getUsage(commandName),
                                        argv=argv, **kwargs)
        except debuggerException, e:
            raise
        except options.OptionError, e:
            e.parser.print_help()
            print >> sys.stderr, e
            sys.exit(e.val)
        except versions.ParseError, e:
            print >> sys.stderr, e
            sys.exit(1)

        argSet.update(newArgSet)
        if argSet.pop('help', False):
            thisCommand.usage()
            sys.exit(1)

        thisCommand.setParser(parser)
        thisCommand.processConfigOptions(cfg, cfgMap, argSet)
        return self.runCommand(thisCommand, cfg, argSet, otherArgs, **kw)
Process argv and execute commands as specified.
dataset/ETHPy150Open sassoftware/conary/conary/lib/mainhandler.py/MainHandler.main