From 4df2ae22570459b05911a39934eb66cfc4abb525 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 6 Jul 2006 21:58:58 +0000 Subject: Add yup script from Jason Pepas git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1912 ce84e21b-d406-0410-9b95-82705330c041 --- tools/yum-listpkgs-xml.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tools/yum-listpkgs-xml.py (limited to 'tools/yum-listpkgs-xml.py') diff --git a/tools/yum-listpkgs-xml.py b/tools/yum-listpkgs-xml.py new file mode 100644 index 000000000..c324d0889 --- /dev/null +++ b/tools/yum-listpkgs-xml.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +import sys +sys.path.append('/usr/bin/') +sys.path.append('/usr/share/yum-cli') + +import yum +import yummain + +def mySimpleList(self, pkg): + print "" % (pkg.name, pkg.printVer()) + +def myListPkgs(self, lst, description, outputType): + """outputs based on whatever outputType is. Current options: + 'list' - simple pkg list + 'info' - similar to rpm -qi output""" + + if outputType in ['list', 'info']: + thingslisted = 0 + if len(lst) > 0: + thingslisted = 1 + #print '%s' % description + from yum.misc import sortPkgObj + lst.sort(sortPkgObj) + for pkg in lst: + if outputType == 'list': + self.simpleList(pkg) + elif outputType == 'info': + self.infoOutput(pkg) + else: + pass + + if thingslisted == 0: + return 1, ['No Packages to list'] + +yummain.cli.output.YumOutput.listPkgs = myListPkgs +yummain.cli.output.YumOutput.simpleList = mySimpleList + +try: + sys.argv = [sys.argv[0],'-d','0','list'] + yummain.main(sys.argv[1:]) +except KeyboardInterrupt, e: + print >> sys.stderr, "\n\nExiting on user cancel." + sys.exit(1) -- cgit v1.2.3-1-g7c22