summaryrefslogtreecommitdiffstats
path: root/contrib/packagekit.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-26 15:47:06 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-26 15:47:06 -0400
commit75c6680924f61c409bcedee8428923282a9096f7 (patch)
tree9549146704c0532454c8c2b337c19db9773bf4af /contrib/packagekit.py
parentc85f1a8272b665ed810ca05b5b31d35a30f00600 (diff)
downloadfunc-75c6680924f61c409bcedee8428923282a9096f7.tar.gz
func-75c6680924f61c409bcedee8428923282a9096f7.tar.xz
func-75c6680924f61c409bcedee8428923282a9096f7.zip
Move packagekit module to contrib directory since the code required to use it is not
in any version of Fedora quite yet and we don't want to answer the user questions about the import errors :) Can move back in once it's all good.
Diffstat (limited to 'contrib/packagekit.py')
-rw-r--r--contrib/packagekit.py92
1 files changed, 92 insertions, 0 deletions
diff --git a/contrib/packagekit.py b/contrib/packagekit.py
new file mode 100644
index 0000000..60091c9
--- /dev/null
+++ b/contrib/packagekit.py
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+
+## func module for PackageKit
+##
+## Copyright 2007, Red Hat, Inc
+## Robin Norwood <rnorwood@redhat.com>
+##
+## This software may be freely redistributed under the terms of the GNU
+## general public license.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+##
+##
+
+
+from codes import *
+from modules import func_module
+
+from packagekit import PackageKit
+
+import StringIO
+
+class PackageKitInterface(PackageKit):
+
+ def __init__(self):
+ PackageKit.__init__(self)
+ self.packages = []
+
+ def Percentage(self, progress):
+ pass
+
+ def JobStatus(self, type):
+ pass
+
+ def Package(self, package_name, package_summary):
+ self.packages.append( {
+ "name" : "%s" % package_name,
+ "summary" : "%s" % package_summary,
+ } )
+
+ def Description(self, package_name, package_group, package_description, package_url):
+ self.packages.append( {
+ "name" : "%s" % package_name,
+ "group" : "%s" % package_group,
+ "description" : "%s" % package_description,
+ "url" : "%s" % package_url,
+ } )
+
+class PackageKitController(func_module.FuncModule):
+
+ def __init__(self):
+ try:
+ self.pkt_interface = PackageKitInterface()
+ except PackageKitNotStarted:
+ func_module.FuncModule.__init__(self)
+ return
+
+ self.methods = {
+ "SearchName" : self.SearchName,
+ "GetDescription" : self.GetDescription,
+ "RefreshCache" : self.RefreshCache,
+ }
+ func_module.FuncModule.__init__(self)
+
+ def SearchName(self, pattern):
+ if len(pattern)==0:
+ return
+
+ self.pkt_interface.job = self.pkt_interface.SearchName(pattern)
+ self.pkt_interface.run()
+
+ return self.pkt_interface.packages
+
+ def GetDescription(self, packageName):
+ if len(packageName) == 0:
+ return
+
+ self.pkt_interface.job = self.pkt_interface.GetDescription(packageName)
+ self.pkt_interface.run()
+
+ return self.pkt_interface.packages
+
+ def RefreshCache(self):
+ self.pkt_interface.job = self.pkt_interface.RefreshCache()
+ self.pkt_interface.run()
+
+ return "Done"
+
+methods = PackageKitController()
+register_rpc = methods.register_rpc