[packagekit] packagekit: Branch 'master' - 6 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Thu Feb 14 11:23:11 PST 2008
backends/yum/helpers/get-packages.py | 22 ++
backends/yum/helpers/yumBackend.py | 39 ++++
backends/yum2/helpers/yumDBUSBackend.py | 75 --------
docs/api/.gitignore | 2
libpackagekit/pk-debug.c | 2
python/packagekit/daemonBackend.py | 294 ++++++++++++++++++++++++++++++++
6 files changed, 359 insertions(+), 75 deletions(-)
New commits:
commit 23b7c3065ab3938763a18856dfd08d9be7b0abfe
Author: Thomas Wood <thomas at openedhand.com>
Date: Thu Feb 14 11:56:28 2008 +0000
Fix gtk-doc comment
diff --git a/libpackagekit/pk-debug.c b/libpackagekit/pk-debug.c
index aeac9ad..c259805 100644
--- a/libpackagekit/pk-debug.c
+++ b/libpackagekit/pk-debug.c
@@ -137,7 +137,7 @@ pk_error_real (const gchar *func, const gchar *file, const int line, const gchar
/**
* pk_debug_enabled:
*
- * Return value: If we have debugging enabled
+ * Returns: TRUE if we have debugging enabled
**/
gboolean
pk_debug_enabled (void)
commit 848af076edb2e476f4b73d28e40b668b05fcb39c
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Thu Feb 14 10:37:12 2008 +0100
Added get-packages and make the yum backend more resistant to UTF-8 decoding errors
diff --git a/backends/yum/helpers/get-packages.py b/backends/yum/helpers/get-packages.py
new file mode 100755
index 0000000..2cf3889
--- /dev/null
+++ b/backends/yum/helpers/get-packages.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+# Copyright (C) 2007 Red Hat Inc, Seth Vidal <skvidal at fedoraproject.org>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+
+options = sys.argv[1]
+
+from yumBackend import PackageKitYumBackend
+
+backend = PackageKitYumBackend(sys.argv[1:],lock=False)
+backend.get_packages(options)
+sys.exit(0)
+
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 394f671..8368b95 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -241,7 +241,11 @@ class PackageKitYumBackend(PackageKitBaseBackend):
convert the description to UTF before sending
'''
desc = self._toUTF(desc)
- PackageKitBaseBackend.description(self,id,license,group,desc,url,bytes)
+ try:
+ PackageKitBaseBackend.description(self,id,license,group,desc,url,bytes)
+ except UnicodeDecodeError,e:
+ summary = repr(desc)[1:-1]
+ PackageKitBaseBackend.description(self,id,license,group,desc,url,bytes)
def package(self,id,status,summary):
'''
@@ -252,7 +256,11 @@ class PackageKitYumBackend(PackageKitBaseBackend):
convert the summary to UTF before sending
'''
summary = self._toUTF(summary)
- PackageKitBaseBackend.package(self,id,status,summary)
+ try:
+ PackageKitBaseBackend.package(self,id,status,summary)
+ except UnicodeDecodeError,e:
+ summary = repr(summary)[1:-1]
+ PackageKitBaseBackend.package(self,id,status,summary)
def _toUTF( self, txt ):
rc=""
@@ -469,6 +477,33 @@ class PackageKitYumBackend(PackageKitBaseBackend):
except yum.Errors.RepoError,e:
self.error(ERROR_NO_CACHE,"Yum cache is invalid")
+ def get_packages(self,filters):
+ '''
+ Search for yum packages
+ @param searchlist: The yum package fields to search in
+ @param filters: package types to search (all,installed,available)
+ @param key: key to seach for
+ '''
+ self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
+ self.yumbase.conf.cache = 1 # Only look in cache.
+ try:
+ fltlist = filters.split(';')
+ available = []
+ count = 1
+ if FILTER_NOT_INSTALLED not in fltlist:
+ for pkg in self.yumbase.rpmdb:
+ if self._do_extra_filtering(pkg,fltlist):
+ self._show_package(pkg, INFO_INSTALLED)
+
+ # Now show available packages.
+ if FILTER_INSTALLED not in fltlist:
+ for pkg in self.yumbase.pkgSack.returnNewestByNameArch():
+ if self._do_extra_filtering(pkg,fltlist):
+ self._show_package(pkg, INFO_AVAILABLE)
+ except yum.Errors.RepoError,e:
+ self.error(ERROR_NO_CACHE,"Yum cache is invalid")
+
+
def search_file(self,filters,key):
'''
Implement the {backend}-search-file functionality
commit c78011cea1b3ea77d887f8512784c6830d9e1bba
Author: Robin Norwood <rnorwood at redhat.com>
Date: Thu Feb 14 00:33:24 2008 -0500
Move abstractable bits back to daemonBackend.py
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 99e4f8d..479d2ec 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -27,6 +27,10 @@
import re
from packagekit.daemonBackend import PackageKitBaseBackend
+
+# This is common between backends
+from packagekit.daemonBackend import PACKAGEKIT_DBUS_INTERFACE, PACKAGEKIT_DBUS_PATH
+
from packagekit.enums import *
from packagekit.daemonBackend import PackagekitProgress
import yum
@@ -222,10 +226,6 @@ def sigquit(signum, frame):
# This is specific to this backend
PACKAGEKIT_DBUS_SERVICE = 'org.freedesktop.PackageKitYumBackend'
-# This is common between backends
-PACKAGEKIT_DBUS_INTERFACE = 'org.freedesktop.PackageKitBackend'
-PACKAGEKIT_DBUS_PATH = '/org/freedesktop/PackageKitBackend'
-
class PackageKitYumBackend(PackageKitBaseBackend):
# Packages there require a reboot
@@ -246,30 +246,10 @@ class PackageKitYumBackend(PackageKitBaseBackend):
# Signals ( backend -> engine -> client )
#
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='s')
- def Finished(self, exit):
- print "Finished (%s)" % (exit)
-
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='ssb')
- def RepoDetail(self, repo_id, description, enabled):
- print "RepoDetail (%s, %s, %i)" % (repo_id, description, enabled)
-
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='b')
- def AllowCancel(self, allow_cancel):
- print "AllowCancel (%i)" % (allow_cancel)
-
#FIXME: _show_description and _show_package wrap Description and
# Package so that the encoding can be fixed. This is ugly.
# we could probably use a decorator to do it instead.
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='sss')
- def Package(self, status, package_id, summary):
- print "Package (%s, %s, %s)" % (status, package_id, summary)
-
def _show_package(self,pkg,status):
'''
send 'package' signal
@@ -282,11 +262,6 @@ class PackageKitYumBackend(PackageKitBaseBackend):
summary = self._toUTF(pkg.summary)
self.Package(status,id,summary)
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='sssssu')
- def Description(self, package_id, license, group, detail, url, size):
- print "Description (%s, %s, %s, %s, %s, %u)" % (package_id, license, group, detail, url, size)
-
def _show_description(self,id,license,group,desc,url,bytes):
'''
Send 'description' signal
@@ -301,48 +276,6 @@ class PackageKitYumBackend(PackageKitBaseBackend):
desc = self._toUTF(desc)
self.Description(id,license,group,desc,url,bytes)
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='ss')
- def Files(self, package_id, file_list):
- print "Files (%s, %s)" % (package_id, file_list)
-
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='s')
- def StatusChanged(self, status):
- print "StatusChanged (%s)" % (status)
-
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='')
- def NoPercentageUpdates(self):
- print "NoPercentageUpdates"
-
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='u')
- def PercentageChanged(self, percentage):
- print "PercentageChanged (%i)" % (percentage)
-
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='u')
- def SubPercentageChanged(self, percentage):
- print "SubPercentageChanged (%i)" % (percentage)
-
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='ssssssss')
- def UpdateDetail(self, package_id, updates, obsoletes, vendor_url, bugzilla_url, cve_url, restart, update):
- print "UpdateDetail (%s, %s, %s, %s, %s, %s, %s, %s)" % (package_id, updates, obsoletes, vendor_url, bugzilla_url, cve_url, restart, update)
-
- @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
- signature='ss')
- def ErrorCode(self, code, description):
- '''
- send 'error'
- @param err: Error Type (ERROR_NO_NETWORK,ERROR_NOT_SUPPORTED,ERROR_INTERNAL_ERROR)
- @param description: Error description
- '''
- print "ErrorCode (%s, %s)" % (code, description)
-
-
-
#
# Utility methods for Signals
#
diff --git a/python/packagekit/daemonBackend.py b/python/packagekit/daemonBackend.py
index 4a3ddf8..7860b8b 100644
--- a/python/packagekit/daemonBackend.py
+++ b/python/packagekit/daemonBackend.py
@@ -33,6 +33,10 @@ import dbus.service
# Classes
+# This is common between backends
+PACKAGEKIT_DBUS_INTERFACE = 'org.freedesktop.PackageKitBackend'
+PACKAGEKIT_DBUS_PATH = '/org/freedesktop/PackageKitBackend'
+
class PackageKitBaseBackend(dbus.service.Object):
def __init__(self, bus_name, dbus_path):
@@ -54,6 +58,296 @@ class PackageKitBaseBackend(dbus.service.Object):
def isLocked(self):
return self._locked
+#
+# Signals ( backend -> engine -> client )
+#
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='s')
+ def Finished(self, exit):
+ print "Finished (%s)" % (exit)
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='ssb')
+ def RepoDetail(self, repo_id, description, enabled):
+ print "RepoDetail (%s, %s, %i)" % (repo_id, description, enabled)
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='b')
+ def AllowCancel(self, allow_cancel):
+ print "AllowCancel (%i)" % (allow_cancel)
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='sss')
+ def Package(self, status, package_id, summary):
+ print "Package (%s, %s, %s)" % (status, package_id, summary)
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='sssssu')
+ def Description(self, package_id, license, group, detail, url, size):
+ print "Description (%s, %s, %s, %s, %s, %u)" % (package_id, license, group, detail, url, size)
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='ss')
+ def Files(self, package_id, file_list):
+ print "Files (%s, %s)" % (package_id, file_list)
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='s')
+ def StatusChanged(self, status):
+ print "StatusChanged (%s)" % (status)
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='')
+ def NoPercentageUpdates(self):
+ print "NoPercentageUpdates"
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='u')
+ def PercentageChanged(self, percentage):
+ print "PercentageChanged (%i)" % (percentage)
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='u')
+ def SubPercentageChanged(self, percentage):
+ print "SubPercentageChanged (%i)" % (percentage)
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='ssssssss')
+ def UpdateDetail(self, package_id, updates, obsoletes, vendor_url, bugzilla_url, cve_url, restart, update):
+ print "UpdateDetail (%s, %s, %s, %s, %s, %s, %s, %s)" % (package_id, updates, obsoletes, vendor_url, bugzilla_url, cve_url, restart, update)
+
+ @dbus.service.signal(dbus_interface=PACKAGEKIT_DBUS_INTERFACE,
+ signature='ss')
+ def ErrorCode(self, code, description):
+ '''
+ send 'error'
+ @param err: Error Type (ERROR_NO_NETWORK,ERROR_NOT_SUPPORTED,ERROR_INTERNAL_ERROR)
+ @param description: Error description
+ '''
+ print "ErrorCode (%s, %s)" % (code, description)
+
+
+
+#
+# Methods ( client -> engine -> backend )
+#
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='', out_signature='')
+ def Init(self):
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='', out_signature='')
+ def Exit(self):
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='', out_signature='')
+ def Lock(self):
+ self.doLock()
+
+ def doLock(self):
+ ''' Lock Yum'''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='', out_signature='')
+ def Unlock(self):
+ self.doUnlock()
+
+ def doUnlock(self):
+ ''' Unlock Yum'''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='ss', out_signature='')
+ def SearchName(self, filters, search):
+ '''
+ Implement the {backend}-search-name functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='ss', out_signature='')
+ def SearchDetails(self,filters,key):
+ '''
+ Implement the {backend}-search-details functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='ss', out_signature='')
+ def SearchGroup(self,filters,key):
+ '''
+ Implement the {backend}-search-group functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='ss', out_signature='')
+ def SearchFile(self,filters,key):
+ '''
+ Implement the {backend}-search-file functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='sb', out_signature='')
+ def GetRequires(self,package,recursive):
+ '''
+ Print a list of requires for a given package
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='sb', out_signature='')
+ def GetDepends(self,package,recursive):
+ '''
+ Print a list of depends for a given package
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='', out_signature='')
+ def UpdateSystem(self):
+ '''
+ Implement the {backend}-update-system functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='', out_signature='')
+ def RefreshCache(self):
+ '''
+ Implement the {backend}-refresh_cache functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='ss', out_signature='')
+ def Resolve(self, filters, name):
+ '''
+ Implement the {backend}-resolve functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='s', out_signature='')
+ def InstallPackage(self, package):
+ '''
+ Implement the {backend}-install functionality
+ This will only work with yum 3.2.4 or higher
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='s', out_signature='')
+ def InstallFile (self, inst_file):
+ '''
+ Implement the {backend}-install_file functionality
+ Install the package containing the inst_file file
+ Needed to be implemented in a sub class
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='s', out_signature='')
+ def UpdatePackage(self, package):
+ '''
+ Implement the {backend}-update functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='sb', out_signature='')
+ def RemovePackage(self, package, allowdep):
+ '''
+ Implement the {backend}-remove functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='s', out_signature='')
+ def GetDescription(self, package):
+ '''
+ Print a detailed description for a given package
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='s', out_signature='')
+ def GetFiles(self, package):
+ '''
+ Implement the get-files method
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='', out_signature='')
+ def GetUpdates(self):
+ '''
+ Implement the {backend}-get-updates functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='sb', out_signature='')
+ def RepoEnable(self, repoid, enable):
+ '''
+ Implement the {backend}-repo-enable functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='', out_signature='')
+ def GetRepoList(self):
+ '''
+ Implement the {backend}-get-repo-list functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='s', out_signature='')
+ def GetUpdateDetail(self,package):
+ '''
+ Implement the {backend}-get-update_detail functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
+
+ @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
+ in_signature='sss', out_signature='')
+ def RepoSetData(self, repoid, parameter, value):
+ '''
+ Implement the {backend}-repo-set-data functionality
+ '''
+ self.ErrorCode(ERROR_NOT_SUPPORTED,"Method not supported")
+ self.Exit()
#
# Utility methods
commit 89c6133866c5b62d51470bbc6cab229e4f4fd5ac
Merge: afaac2a... 39f036e...
Author: Robin Norwood <rnorwood at redhat.com>
Date: Wed Feb 13 22:16:49 2008 -0500
Merge branch 'master' of git+ssh://rnorwood@git.packagekit.org/srv/git/PackageKit
commit 39f036e7e745200a14e81b69097d9b77ad335a9f
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Thu Feb 14 01:23:25 2008 +0200
Update .gitignore with version.xml
diff --git a/docs/api/.gitignore b/docs/api/.gitignore
index ee8697d..5c75779 100644
--- a/docs/api/.gitignore
+++ b/docs/api/.gitignore
@@ -19,4 +19,4 @@ sgml-build.stamp
sgml.stamp
tmpl-build.stamp
tmpl.stamp
-
+version.xml
commit afaac2a4de7f0ec48708305d18501f5eb19f75e4
Author: Robin Norwood <rnorwood at redhat.com>
Date: Wed Feb 13 14:30:39 2008 -0500
If it was true the first time, no need to say so again.
diff --git a/src/pk-backend-dbus.c b/src/pk-backend-dbus.c
index c196166..cd7e450 100644
--- a/src/pk-backend-dbus.c
+++ b/src/pk-backend-dbus.c
@@ -404,8 +404,6 @@ pk_backend_dbus_set_name (PkBackendDbus *backend_dbus, const gchar *service,
backend_dbus, NULL,
G_TYPE_INVALID, G_TYPE_INVALID);
return TRUE;
-
- return TRUE;
}
/**
More information about the PackageKit
mailing list