List installed pkgs (smaller than the "yum list" snippet).
# This uses rpm directly: import rpm ts = rpm.TransactionSet() ts.setVSFlags((rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS)) for hdr in ts.dbMatch(): # No sorting if hdr['name'] == 'gpg-pubkey': continue else: print '%s-%s:%s-%s.%s' % (hdr['name'], hdr['epochnum'],hdr['version'],hdr['release'], hdr['arch']) # Via. yum import yum yb = yum.YumBase() yb.conf.cache = 1 for pkg in sorted(yb.rpmdb.returnPackages()): print pkg, pkg.repo