本文整理汇总了Python中yum.YumBase类的典型用法代码示例。如果您正苦于以下问题:Python YumBase类的具体用法?Python YumBase怎么用?Python YumBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了YumBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, cache, tmp, repo_pattern="*debug*", keep_rpms=False,
noninteractive=True):
self.old_stdout = -1
self.cachedir = cache
self.tmpdir = tmp
global TMPDIR
TMPDIR = tmp
self.keeprpms = keep_rpms
self.noninteractive = noninteractive
self.repo_pattern=repo_pattern
YumBase.__init__(self)
self.mute_stdout()
#self.conf.cache = os.geteuid() != 0
# Setup yum (Ts, RPM db, Repo & Sack)
# doConfigSetup() takes some time, let user know what we are doing
print _("Initializing yum")
try:
# Saw this exception here:
# cannot open Packages index using db3 - Permission denied (13)
# yum.Errors.YumBaseError: Error: rpmdb open failed
self.doConfigSetup()
except YumBaseError, ex:
self.unmute_stdout()
print _("Error initializing yum (YumBase.doConfigSetup): '{0!s}'").format(ex)
#return 1 - can't do this in constructor
exit(1)
开发者ID:tylerwhall,项目名称:libreport,代码行数:26,代码来源:debuginfo.py
示例2: testable
def testable(self):
""" Get a list of installed testing updates.
This method is a generate that yields packages that you currently
have installed that you have yet to test and provide feedback for.
"""
from yum import YumBase
yum = YumBase()
yum.doConfigSetup(init_plugins=False)
with open('/etc/fedora-release', 'r') as f:
fedora = f.readlines()[0].split()[2]
tag = 'f%s-updates-testing' % fedora
builds = self.get_koji_session(
login=False).listTagged(tag, latest=True)
for build in builds:
pkgs = yum.rpmdb.searchNevra(name=build['name'],
ver=build['version'],
rel=build['release'],
epoch=None,
arch=None)
if len(pkgs):
update_list = self.query(package=[build['nvr']])['updates']
for update in update_list:
yield update
开发者ID:fedora-infra,项目名称:python-fedora,代码行数:25,代码来源:bodhi.py
示例3: get_yum_releasever
def get_yum_releasever(yumbase=None):
if not yumbase:
yumbase = YumBase()
yumbase.doConfigSetup(init_plugins=False)
yum_releaseversion = yumbase.conf.yumvar['releasever']
releasever = yum_releaseversion.lower().replace('server', '')
return releasever
开发者ID:esc,项目名称:yadt-minion,代码行数:7,代码来源:yadtminionutils.py
示例4: __init__
def __init__(self, importkeys=False, progress=None):
"""
Construct a customized instance of YumBase.
This includes:
- loading yum plugins.
- custom configuration.
- setting the progress bar for download progress reporting.
- prime our progress report object.
:param importkeys: Allow the import of GPG keys.
:type importkeys: bool
:param progress: A progress reporting object.
:type progress: ProgressReport
"""
parser = OptionParser()
parser.parse_args([])
self.__parser = parser
YumBase.__init__(self)
self.preconf.optparser = self.__parser
self.preconf.plugin_types = (TYPE_CORE, TYPE_INTERACTIVE)
self.conf.assumeyes = importkeys
self.progress = progress or ProgressReport()
bar = DownloadCallback(self.progress)
self.repos.setProgressBar(bar)
self.progress.push_step('Refresh Repository Metadata')
self.logfile = getLogger('yum.filelogging')
开发者ID:bkearney,项目名称:pulp_rpm,代码行数:25,代码来源:rpmtools.py
示例5: _make_yum_base
def _make_yum_base():
global _yum_base
if _yum_base is None:
# This seems needed...
# otherwise 'cannot open Packages database in /var/lib/rpm' starts to happen
with sh.Rooted(True):
_yum_base = YumBase()
_yum_base.setCacheDir(force=True)
return _yum_base
开发者ID:gerardo8a,项目名称:Openstack-Anvil,代码行数:9,代码来源:yum_helper.py
示例6: _get_yum_base
def _get_yum_base():
if Helper._yum_base is None:
# This 'root' seems needed...
# otherwise 'cannot open Packages database in /var/lib/rpm' starts to happen
with sh.Rooted(True):
_yum_base = YumBase()
_yum_base.setCacheDir(force=True)
Helper._yum_base = _yum_base
return Helper._yum_base
开发者ID:apugachev-gd,项目名称:Openstack-Anvil,代码行数:9,代码来源:yum_helper.py
示例7: doPluginSetup
def doPluginSetup(self, *args, **kwargs):
"""
Set command line arguments.
Support TYPE_INTERACTIVE plugins.
"""
YumBase.doPluginSetup(self, *args, **kwargs)
p = self.__parser
options, args = p.parse_args([])
self.plugins.setCmdLine(options, args)
开发者ID:AndreaGiardini,项目名称:pulp_rpm,代码行数:9,代码来源:rpmtools.py
示例8: close
def close(self):
"""
This should be handled by __del__() but YumBase
objects never seem to completely go out of scope and
garbage collected.
"""
YumBase.close(self)
self.closeRpmDB()
self.cleanLoggers()
开发者ID:AndreaGiardini,项目名称:pulp_rpm,代码行数:9,代码来源:rpmtools.py
示例9: __init__
def __init__(self, importkeys=False):
"""
@param importkeys: Allow the import of GPG keys.
@type importkeys: bool
"""
parser = OptionParser()
parser.parse_args([])
self.__parser = parser
YumBase.__init__(self)
self.preconf.optparser = self.__parser
self.preconf.plugin_types = (TYPE_CORE, TYPE_INTERACTIVE)
self.conf.assumeyes = importkeys
开发者ID:splice,项目名称:gofer,代码行数:12,代码来源:package.py
示例10: processTransaction
def processTransaction(self):
"""
Process the transaction.
The method is overridden so we can add progress reporting.
The *callback* is used to report high-level progress.
The *display* is used to report rpm-level progress.
"""
try:
callback = ProcessTransCallback(self.progress)
display = RPMCallback(self.progress)
YumBase.processTransaction(self, callback, rpmDisplay=display)
self.progress.set_status(True)
except Exception:
self.progress.set_status(False)
raise
开发者ID:AndreaGiardini,项目名称:pulp_rpm,代码行数:15,代码来源:rpmtools.py
示例11: __init__
def __init__(self, cache, tmp, repo_pattern="*debug*", keep_rpms=False,
noninteractive=True, releasever=None):
super(YumDebugInfoDownload, self).__init__(cache, tmp, repo_pattern, keep_rpms, noninteractive)
self.base = YumBase()
if not releasever is None:
self.base.conf.substitutions['releasever'] = releasever
开发者ID:abrt,项目名称:libreport,代码行数:7,代码来源:yumdebuginfo.py
示例12: __init__
def __init__(self, cache, tmp, keep_rpms=False):
self.cachedir = cache
self.tmpdir = tmp
self.keeprpms = keep_rpms
YumBase.__init__(self)
mute_stdout()
#self.conf.cache = os.geteuid() != 0
# Setup yum (Ts, RPM db, Repo & Sack)
try:
# Saw this exception here:
# cannot open Packages index using db3 - Permission denied (13)
# yum.Errors.YumBaseError: Error: rpmdb open failed
self.doConfigSetup()
except Exception, e:
unmute_stdout()
print _("Error initializing yum (YumBase.doConfigSetup): '%s'") % str(e)
#return 1 - can't do this in constructor
exit(1)
开发者ID:wyuka,项目名称:abrt,代码行数:18,代码来源:abrt-action-install-debuginfo.py
示例13: _init
def _init(self):
from yum import YumBase
yum = YumBase()
yum.setCacheDir()
# urlgrabber is a 3rd party module
# try:
# if sys.stdout.isatty():
# import imp
# from urlgrabber.progress import TextMeter
# output = imp.load_source("output", "/usr/share/yum=cli")
# yum.repos.setProgressBar(TextMeter(fo=sys.stdout))
# yum.repos.callback = output.CacheProgressCallback()
# yumout = output.YumOutput()
# freport = ( yumout.failureReport, (), {} )
# yum.repos.setFailureCallback( freport )
# except:
# print("Warning: Unable to set progress indicator")
return yum
开发者ID:fwin-dev,项目名称:py.OS,代码行数:20,代码来源:_yum.py
示例14: resolveCode
def resolveCode(self):
solver = YumBase()
solver.save_ts = save_ts
solver.conf = FakeConf()
solver.arch.setup_arch('x86_64')
solver.tsInfo = solver._tsInfo = self.tsInfo
solver.rpmdb = self.rpmdb
solver.pkgSack = self.xsack
for po in self.rpmdb:
po.repoid = po.repo.id = "installed"
for po in self.xsack:
if po.repo.id is None:
po.repo.id = "TestRepository"
po.repoid = po.repo.id
for txmbr in self.tsInfo:
if txmbr.ts_state in ('u', 'i'):
if txmbr.po.repo.id is None:
txmbr.po.repo.id = "TestRepository"
txmbr.po.repoid = txmbr.po.repo.id
else:
txmbr.po.repoid = txmbr.po.repo.id = "installed"
result, msg = solver.resolveDeps()
return (self.res[result], msg)
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:25,代码来源:testbase.py
示例15: _run_transaction
def _run_transaction(transaction_name, install_mode, remove_mode):
import os
from yum import YumBase
transaction = open(os.path.join(config.STACKDIR, transaction_name),
'r')
my_yum = YumBase()
for line in transaction:
line = line.strip()
parts = line.split(' ')
if parts[0] == install_mode:
fn = my_yum.install
elif parts[0] == remove_mode:
fn = my_yum.remove
else:
assert False, "corrupt transaction file"
if parts[2] == 'None':
parts[2] = None
fn(name=parts[1], epoch=parts[2], version=parts[3],
release=parts[4], arch=parts[5])
dlpkgs = map(lambda x: x.po, filter(lambda txmbr:
txmbr.ts_state in ("i", "u"),
my_yum.tsInfo.getMembers()))
my_yum.downloadPkgs(dlpkgs)
my_yum.initActionTs() # make a new, blank ts to populate
my_yum.populateTs(keepold=0)
my_yum.ts.check() #required for ordering
my_yum.ts.order() # order
# FIXME: is it really sane to use this from here?
import sys
sys.path.append('/usr/share/yum-cli')
import callback
cb = callback.RPMInstallCallback(output = 0)
cb.filelog = True
cb.tsInfo = my_yum.tsInfo
my_yum.runTransaction(cb)
开发者ID:jbowes,项目名称:yq,代码行数:43,代码来源:yumbackend.py
示例16: __init__
def __init__(self):
YumBase.__init__(self)
self.conf.assumeyes = True
开发者ID:barnzdan,项目名称:satellite-register,代码行数:3,代码来源:satellite.py
示例17: Copyright
#coding: utf-8
#
# Ailurus - a simple application installer and GNOME tweaker
#
# Copyright (C) 2009-2010, Ailurus developers and Ailurus contributors
# Copyright (C) 2007-2010, Trusted Digital Technology Laboratory, Shanghai Jiao Tong University, China.
#
# Ailurus is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Ailurus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ailurus; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import sys
from yum import YumBase
base = YumBase()
ygh = base.doPackageLists()
for available in ygh.available:
name = available.pkgtup[0]
print >>sys.stderr, name # because base.doPackageLists prints text to stdout
开发者ID:esunny,项目名称:Ailurus,代码行数:28,代码来源:dump_rpm_existing.py
示例18: __init__
def __init__(self, cache, tmp, repo_pattern="*debug*", keep_rpms=False,
noninteractive=True):
super(YumDebugInfoDownload, self).__init__(cache, tmp, repo_pattern, keep_rpms, noninteractive)
self.base = YumBase()
开发者ID:scottgfhong,项目名称:libreport,代码行数:5,代码来源:yumdebuginfo.py
示例19: YumDebugInfoDownload
class YumDebugInfoDownload(DebugInfoDownload):
def __init__(self, cache, tmp, repo_pattern="*debug*", keep_rpms=False,
noninteractive=True):
super(YumDebugInfoDownload, self).__init__(cache, tmp, repo_pattern, keep_rpms, noninteractive)
self.base = YumBase()
def initialize_progress(self, updater):
self.progress = YumDownloadCallback(updater)
self.base.repos.setProgressBar(self.progress)
self.base.repos.setMirrorFailureCallback(downloadErrorCallback)
def prepare(self):
self.mute_stdout()
#self.conf.cache = os.geteuid() != 0
# Setup yum (Ts, RPM db, Repo & Sack)
# doConfigSetup() takes some time, let user know what we are doing
try:
# Saw this exception here:
# cannot open Packages index using db3 - Permission denied (13)
# yum.Errors.YumBaseError: Error: rpmdb open failed
self.base.doConfigSetup()
except YumBaseError as ex:
self.unmute_stdout()
print(_("Error initializing yum (YumBase.doConfigSetup): '{0!s}'").format(str(ex)))
#return 1 - can't do this in constructor
exit(1)
self.unmute_stdout()
# make yumdownloader work as non root user
if not self.base.setCacheDir():
print(_("Error: can't make cachedir, exiting"))
return RETURN_FAILURE
# disable all not needed
for repo in self.base.repos.listEnabled():
try:
repo.close()
self.base.repos.disableRepo(repo.id)
except YumBaseError as ex:
print(_("Can't disable repository '{0!s}': {1!s}").format(repo.id, str(ex)))
def initialize_repositories(self):
# setting-up repos one-by-one, so we can skip the broken ones...
# this helps when users are using 3rd party repos like rpmfusion
# in rawhide it results in: Can't find valid base url...
for r in self.base.repos.findRepos(pattern=self.repo_pattern):
try:
rid = self.base.repos.enableRepo(r.id)
self.base.repos.doSetup(thisrepo=str(r.id))
log1("enabled repo %s", rid)
setattr(r, "skip_if_unavailable", True)
# yes, we want async download, otherwise our progressCallback
# is not called and the internal yum's one is used,
# which causes artifacts on output
try:
setattr(r, "_async", False)
except (NameError, AttributeError) as ex:
print(str(ex))
print(_("Can't disable async download, the output might contain artifacts!"))
except YumBaseError as ex:
print(_("Can't setup {0}: {1}, disabling").format(r.id, str(ex)))
self.base.repos.disableRepo(r.id)
# This is somewhat "magic", it unpacks the metadata making it usable.
# Looks like this is the moment when yum talks to remote servers,
# which takes time (sometimes minutes), let user know why
# we have "paused":
try:
self.base.repos.populateSack(mdtype='metadata', cacheonly=1)
except YumBaseError as ex:
print(_("Error retrieving metadata: '{0!s}'").format(str(ex)))
#we don't want to die here, some metadata might be already retrieved
# so there is a chance we already have what we need
#return 1
try:
# Saw this exception here:
# raise Errors.NoMoreMirrorsRepoError, errstr
# NoMoreMirrorsRepoError: failure:
# repodata/7e6632b82c91a2e88a66ad848e231f14c48259cbf3a1c3e992a77b1fc0e9d2f6-filelists.sqlite.bz2
# from fedora-debuginfo: [Errno 256] No more mirrors to try.
self.base.repos.populateSack(mdtype='filelists', cacheonly=1)
except YumBaseError as ex:
print(_("Error retrieving filelists: '{0!s}'").format(str(ex)))
# we don't want to die here, some repos might be already processed
# so there is a chance we already have what we need
#return 1
def triage(self, files):
not_found = []
package_files_dict = {}
todownload_size = 0
installed_size = 0
for debuginfo_path in files:
log2("yum whatprovides %s", debuginfo_path)
pkg = self.base.pkgSack.searchFiles(debuginfo_path)
# sometimes one file is provided by more rpms, we can use either of
# them, so let's use the first match
#.........这里部分代码省略.........
开发者ID:scottgfhong,项目名称:libreport,代码行数:101,代码来源:yumdebuginfo.py
示例20: main
def main(directory, version):
"""
Update packages in directory and install all those available
@type directory: string
@param directory: path to the directory which contains a copy of the whole system
@type version: string
@param version: PowerKVM version used to update system
@rtype: boolean
@returns: True if the packages was successfully updated;
False otherwise
"""
os.chroot(directory)
# update all packages
yumBase = YumBase()
# get all enabled repos
enabledRepos = yumBase.repos.listEnabled()
# disable all yum repos
yumBase.repos.disableRepo('*')
# enable only the powerkvm repo
yumBase.repos.enableRepo('powerkvm-%s' % version)
# update system
yumBase.update()
rc, msgs = yumBase.buildTransaction()
if rc != 2:
return False
try:
yumBase.processTransaction()
except:
return False
# check if there is more than one kernel installed
# if so, remove one
availableKernels = yumBase.searchPackages(['name'], ['kernel'])
installedKernels = 0
for pkg in availableKernels:
if pkg.repoid == 'installed' and pkg.name == 'kernel':
installedKernels += 1
if installedKernels != 1:
yumBase.remove(name='kernel')
# install new packages available in the repo
pkgs = yumBase.doPackageLists().available
for pkg in pkgs:
yumBase.install(pkg)
# build and process the YUM transaction
rc, msgs = yumBase.buildTransaction()
if rc != 2:
return False
try:
yumBase.processTransaction()
except:
return False
# re-enable the repos
for repo in enabledRepos:
repo.enable()
return True
开发者ID:bjwt,项目名称:leopard,代码行数:72,代码来源:updatepackages.py
注:本文中的yum.YumBase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论