def _yb_no_pri(self): npyb = YumUtilBase(NAME, VERSION, USAGE) npyb.preconf.disabled_plugins = ['priorities'] npyb.preconf.quiet = True npyb.preconf.debuglevel = -1 npyb.preconf.errorlevel = -1 opt_prsr = OptionParser() npyb.preconf.optparser = opt_prsr npyb.conf.cache = os.geteuid() != 0 npyb.conf.disable_excludes = ['all'] opts, args = opt_prsr.parse_args([]) npyb.plugins.setCmdLine(opts, args) return npyb
def _init_yumbase(self, name=NAME, ver=VERSION, usage=USAGE): yum_base = YumUtilBase(name, ver, usage) yum_base.preconf.disableplugin = [] yum_base.preconf.quiet = True yum_base.preconf.debuglevel = -1 yum_base.preconf.errorlevel = -1 yum_base.preconf.plugin_types = (plugins.TYPE_CORE, plugins.TYPE_INTERACTIVE) opt_prsr = OptionParser() yum_base.preconf.optparser = opt_prsr yum_base.conf.cache = os.geteuid() != 0 yum_base.conf.disable_excludes = [] opts, args = opt_prsr.parse_args([]) # The yum security plugin will crap pants if the plugin # cmdline isn't set up: yum_base.plugins.setCmdLine(opts, args) return yum_base
fp =file(filename, "w") fp.write(str(ini)) fp.close() def match_repoid(repoid, repo_setopts): for i in repo_setopts: if fnmatch.fnmatch(repoid, i): return True NAME = 'yum-config-manager' VERSION = '1.0' USAGE = 'yum-config-manager [options] [section ...]' yum.misc.setup_locale() yb = YumUtilBase(NAME, VERSION, USAGE) logger = logging.getLogger("yum.verbose.cli.yum-config-manager") yb.preconf.debuglevel = 0 yb.preconf.errorlevel = 0 yb.optparser = yb.getOptionParser() if hasattr(yb, 'getOptionGroup'): # check if the group option API is available group = yb.getOptionGroup() else: group = yb.optparser group.add_option("--save", default=False, action="store_true", help='save the current options (useful with --setopt)') group.add_option("--enable", default=False, action="store_true", help='enable the specified repos (automatically saves)') group.add_option("--disable", default=False, action="store_true", help='disable the specified repos (automatically saves)') group.add_option("--add-repo", default=[], dest='addrepo', action='append',