Package pulp :: Package client :: Module package_profile
[hide private]
[frames] | no frames]

Source Code for Module pulp.client.package_profile

 1  #!/usr/bin/python 
 2  # 
 3  # Copyright (c) 2010 Red Hat, Inc. 
 4  # 
 5  # This software is licensed to you under the GNU General Public License, 
 6  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 7  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 8  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 9  # along with this software; if not, see 
10  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
11  # 
12  # Red Hat trademarks are not licensed under GPLv2. No permission is 
13  # granted to use or replicate Red Hat trademarks that are incorporated 
14  # in this software or its documentation. 
15  # 
16  from pulp.client.logutil import getLogger 
17  import utils 
18  import rpm 
19  log = getLogger(__name__) 
20   
21  """ 
22  Module for Package profile accumulation 
23  """ 
24   
25 -class PackageProfile(object):
26 """ 27 Class for probing package profile info 28 @ivar type: type of package content to run lookups on eg: 'rpm','jar','zip' etc. 29 @type TYPE: str 30 """
31 - def __init__(self, type='rpm'):
32 self.pkgtype = type 33 self.pkglist = {}
34
35 - def getPackageList(self):
36 """ 37 Get I{ordered} pkg hash objects. 38 @return: A list of ordered pkg hash objects. 39 @rtype: list 40 """ 41 if self.pkgtype == 'rpm': 42 return self.__getInstalledRpms()
43
44 - def __getInstalledRpms(self):
45 """ Accumulates list of installed rpm info """ 46 ts = rpm.TransactionSet() 47 ts.setVSFlags(-1) 48 installed = ts.dbMatch() 49 self.pkglist = utils.generatePakageProfile(installed) 50 return self.pkglist
51
52 - def _getInstalledJars(self):
53 pass
54
55 - def _getInstalledZips(self):
56 pass
57 58 59 if __name__ == '__main__': 60 pp = PackageProfile() 61 import pprint 62 pprint.pprint(pp.getPackageList()) 63