Changes from Version 1 of YumCodeSnippet/ListInstalledPkgs

Show
Ignore:
Author:
james (IP: 65.172.155.230)
Timestamp:
10/01/10 15:22:58 (7 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • YumCodeSnippet/ListInstalledPkgs

    v0 v1  
     1List installed pkgs (smaller than the "[YumCodeSnippet/YumList yum list]" snippet). 
     2 
     3{{{ 
     4#!python 
     5 
     6# This uses rpm directly: 
     7import rpm 
     8 
     9ts = rpm.TransactionSet() 
     10ts.setVSFlags((rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS)) 
     11for hdr in ts.dbMatch(): # No sorting 
     12    if hdr['name'] == 'gpg-pubkey': 
     13        continue 
     14    else: 
     15        print '%s-%s:%s-%s.%s' % (hdr['name'], 
     16                                  hdr['epochnum'],hdr['version'],hdr['release'], 
     17                                  hdr['arch']) 
     18 
     19 
     20 
     21# Via. yum 
     22import yum 
     23yb = yum.YumBase() 
     24yb.conf.cache = 1 
     25for pkg in sorted(yb.pkgSack.returnPackages()): 
     26    print pkg, pkg.repo 
     27}}}