[Yum-devel] Yum API Question

Keith Robertson kroberts at redhat.com
Sun Jan 20 17:14:31 UTC 2013


Hi,

I've been trying to write some code which uses the Yum API to download 
some packages based on an example in[1].  I have written a very simple 
program[2] which is successfully downloading packages to an 
'installroot' of my choosing.  Unfortunately, I am getting some odd 
exceptions that I am not quite sure how to fix.  I feel like there is an 
initialization function(s) that I might be neglecting to call on YumBase 
but I can't figure out what it is.  Importantly, the files do get 
downloaded and unpacked into my 'installroot'.

Questions:
1) Should I just ignore/eat the error since the files do seem to get 
downloaded?
2) Is there some initialization function I am neglecting to call or is 
there a debug option I can use to squelch all output from yum (see 
stacktrace in [3])?

Cheers,
Keith

[1] http://yum.baseurl.org/wiki/5MinuteExamples

[2] My program:
import sys
import yum
import traceback
from urlgrabber.progress import TextMeter

if __name__ == '__main__':
     # Init yum
     yb = yum.YumBase()

     # Do this according to example.
     if hasattr(yum.YumBase, 'setCacheDir'):
         # Newer version appear to use this
         print 'setCacheDir'
         yb.setCacheDir()
     else:
         # Older use this.
         print '_getConfig'
         yb._getConfig()

     yb.conf.installroot = '/tmp/yumtest'
     yb.conf.gpgcheck = False
     print yb.conf
     yb.repos.setProgressBar(TextMeter(fo=sys.stdout))

     try:
         print yb.repos.disableRepo('*')
         print yb.repos.enableRepo('*-debug*')
         pkgAry = 
yb.pkgSack.returnPackages(patterns=['kernel-debuginfo-3.3.4-5*'])
         print yb.install(pkgAry[0])
         print yb.resolveDeps()
         print yb.processTransaction()
     except Exception, e:
         print e
         exc_type, exc_value, exc_traceback = sys.exc_info()
         traceback.print_exception(exc_type, exc_value, exc_traceback,
                                   limit=5, file=sys.stdout)

     pass

[3]
<snipped some extraneous output>
  * updates-testing-debuginfo: archive.linux.duke.edu
[<TransactionMember : kernel-debuginfo.x86_64 0:3.3.4-5.fc17 - u 
(0x30519e0)>]
(2, [u'Success - deps resolved'])
(1/2): kernel-debuginfo-3.3.4-5.fc17.x86_64.rpm | 240 MB     00:36
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 
1aca3465: NOKEY
Public key for kernel-debuginfo-3.3.4-5.fc17.x86_64.rpm is not installed
(2/2): kernel-debuginfo-common-x86_64-3.3.4-5.fc17.x86_64.rpm |  39 
MB     00:11
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-x86_64
Importing GPG key 0x1ACA3465:
  Userid     : "Fedora (17) <fedora at fedoraproject.org>"
  Fingerprint: cac4 3fb7 74a4 a673 d81c 5de7 50e9 4c99 1aca 3465
  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-x86_64
Didn't install any keys
Traceback (most recent call last):
   File "yumtest.py", line 34, in <module>
     print yb.processTransaction()
   File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 6085, 
in processTransaction
     self._checkSignatures(pkgs,callback)
   File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 6128, 
in _checkSignatures
     self.getKeyForPackage(po, self._askForGPGKeyImport)
   File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 5830, 
in getKeyForPackage
     raise Errors.YumBaseError, _("Didn't install any keys")
YumBaseError: Didn't install any keys

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20130120/5280b22c/attachment.html>


More information about the Yum-devel mailing list