[packagekit] packagekit: Branch 'master' - 4 commits

Richard Hughes hughsient at kemper.freedesktop.org
Tue Nov 6 14:11:48 PST 2007


 Makefile.am                              |    2 
 backends/apt/helpers/aptBackend.py       |    8 +-
 backends/conary/helpers/conaryBackend.py |    8 +-
 backends/pisi/helpers/pisiBackend.py     |    4 -
 backends/smart/helpers/smartBackend.py   |    4 -
 backends/yum/helpers/yumBackend.py       |   16 ++---
 client/pk-console.c                      |    2 
 configure.ac                             |    2 
 html/img/Makefile.am                     |    3 -
 libpackagekit/pk-enum.c                  |    6 +-
 libpackagekit/pk-enum.h                  |    6 +-
 python/Makefile.am                       |    2 
 python/enum-convertor.py                 |   24 ++++++++
 python/packagekit/.gitignore             |    2 
 python/packagekit/Makefile.am            |    4 +
 python/packagekit/backend.py             |   86 -------------------------------
 python/packagekit/frontend.py            |   15 +----
 python/pk-frontend-test.py               |    4 -
 18 files changed, 72 insertions(+), 126 deletions(-)

New commits:
commit 3a5d265a935766e5ace6a1f5c3a9855d2554ccbe
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Nov 6 22:07:12 2007 +0000

    make the filter enums more sane

diff --git a/backends/apt/helpers/aptBackend.py b/backends/apt/helpers/aptBackend.py
index 8122474..314b826 100644
--- a/backends/apt/helpers/aptBackend.py
+++ b/backends/apt/helpers/aptBackend.py
@@ -341,15 +341,15 @@ class PackageKitAptBackend(PackageKitBaseBackend):
             return True
         if (FILTER_INSTALLED in filters) and (not package.is_installed):
             return False
-        if (FILTER_NON_INSTALLED in filters) and package.is_installed:
+        if (FILTER_NOT_INSTALLED in filters) and package.is_installed:
             return False
         if (FILTER_GUI in filters) and (not package.is_gui):
             return False
-        if (FILTER_NON_GUI in filters) and package.is_gui:
+        if (FILTER_NOT_GUI in filters) and package.is_gui:
             return False
-        if (FILTER_DEVEL in filters) and (not package.is_development):
+        if (FILTER_DEVELOPMENT in filters) and (not package.is_development):
             return False
-        if (FILTER_NON_DEVEL in filters) and package.is_development:
+        if (FILTER_NOT_DEVELOPMENT in filters) and package.is_development:
             return False
         return TRUE
 
diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index a32be0d..7a0c3a7 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -308,7 +308,7 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
             return True
         elif FILTER_INSTALLED in filterList and installed == INFO_INSTALLED:
             do_print = True
-        elif FILTER_NON_INSTALLED in filterList and installed == INFO_AVAILABLE:
+        elif FILTER_NOT_INSTALLED in filterList and installed == INFO_AVAILABLE:
             do_print = True
 
         if len(filterList) == 1: # Only one filter, return
@@ -323,16 +323,16 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
         ''' do extra filtering (devel etc) '''
 
         for filter in filterList:
-            if filter in (FILTER_INSTALLED, FILTER_NON_INSTALLED):
+            if filter in (FILTER_INSTALLED, FILTER_NOT_INSTALLED):
                 continue
-            elif filter in (FILTER_DEVEL, FILTER_NON_DEVEL):
+            elif filter in (FILTER_DEVELOPMENT, FILTER_NOT_DEVELOPMENT):
                 if not self._do_devel_filtering(flt,pkg):
                     return False
         return True
 
     def _do_devel_filtering(self, flt, pkg):
         isDevel = False
-        if flt == FILTER_DEVEL:
+        if flt == FILTER_DEVELOPMENT:
             wantDevel = True
         else:
             wantDevel = False
diff --git a/backends/pisi/helpers/pisiBackend.py b/backends/pisi/helpers/pisiBackend.py
index e6ad922..ca4482d 100644
--- a/backends/pisi/helpers/pisiBackend.py
+++ b/backends/pisi/helpers/pisiBackend.py
@@ -137,11 +137,11 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
 
                 if FILTER_INSTALLED in filterlist and status != INFO_INSTALLED:
                     return
-                if FILTER_NON_INSTALLED in filterlist and status == INFO_INSTALLED:
+                if FILTER_NOT_INSTALLED in filterlist and status == INFO_INSTALLED:
                     return
                 if FILTER_GUI in filterlist and "app:gui" not in pkg.isA:
                     return
-                if FILTER_NON_GUI in filterlist and "app:gui" in pkg.isA:
+                if FILTER_NOT_GUI in filterlist and "app:gui" in pkg.isA:
                     return
 
         version = self.__get_package_version(pkg)
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index a850a16..120e57d 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -18,7 +18,7 @@
 
 import smart
 from packagekit.backend import PackageKitBaseBackend, INFO_INSTALLED, \
-        INFO_AVAILABLE, INFO_NORMAL, FILTER_NON_INSTALLED, FILTER_INSTALLED, \
+        INFO_AVAILABLE, INFO_NORMAL, FILTER_NOT_INSTALLED, FILTER_INSTALLED, \
         ERROR_REPO_NOT_FOUND, ERROR_PACKAGE_ALREADY_INSTALLED
 
 
@@ -318,5 +318,5 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
     def _passes_filters(package, filters):
         filterlist = filters.split(';')
 
-        return (FILTER_NON_INSTALLED not in filterlist and package.installed
+        return (FILTER_NOT_INSTALLED not in filterlist and package.installed
                 or FILTER_INSTALLED not in filterlist and not package.installed)
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 2a45d04..3f8d07e 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -302,7 +302,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 count+=1
                 # are we installed?
                 if pkg.repoid == 'installed':
-                    if FILTER_NON_INSTALLED not in fltlist:
+                    if FILTER_NOT_INSTALLED not in fltlist:
                         if self._do_extra_filtering(pkg,fltlist):
                             self._show_package(pkg, INFO_INSTALLED)
                 else:
@@ -319,12 +319,12 @@ class PackageKitYumBackend(PackageKitBaseBackend):
     def _do_extra_filtering(self,pkg,filterList):
         ''' do extra filtering (gui,devel etc) '''
         for filter in filterList:
-            if filter in (FILTER_INSTALLED, FILTER_NON_INSTALLED):
+            if filter in (FILTER_INSTALLED, FILTER_NOT_INSTALLED):
                 continue
-            elif filter in (FILTER_GUI, FILTER_NON_GUI):
+            elif filter in (FILTER_GUI, FILTER_NOT_GUI):
                 if not self._do_gui_filtering(filter, pkg):
                     return False
-            elif filter in (FILTER_DEVEL, FILTER_NON_DEVEL):
+            elif filter in (FILTER_DEVELOPMENT, FILTER_NOT_DEVELOPMENT):
                 if not self._do_devel_filtering(filter, pkg):
                     return False
         return True
@@ -351,7 +351,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
 
     def _do_devel_filtering(self,flt,pkg):
         isDevel = False
-        if flt == FILTER_DEVEL:
+        if flt == FILTER_DEVELOPMENT:
             wantDevel = True
         else:
             wantDevel = False
@@ -412,7 +412,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
             fltlist = filters.split(';')
             found = {}
 
-            if not FILTER_NON_INSTALLED in fltlist:
+            if not FILTER_NOT_INSTALLED in fltlist:
                 # Check installed for group
                 for pkg in self.yumbase.rpmdb:
                     group = GROUP_OTHER                    # Default Group
@@ -447,7 +447,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         #self.yumbase.conf.cache = 1 # Only look in cache.
         fltlist = filters.split(';')
         found = {}
-        if not FILTER_NON_INSTALLED in fltlist:
+        if not FILTER_NOT_INSTALLED in fltlist:
             # Check installed for file
             for pkg in self.yumbase.rpmdb:
                 filelist = pkg.filelist
@@ -673,7 +673,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         try:
             # Get installed packages
             installedByKey = self.yumbase.rpmdb.searchNevra(name=name)
-            if FILTER_NON_INSTALLED not in fltlist:
+            if FILTER_NOT_INSTALLED not in fltlist:
                 for pkg in installedByKey:
                     self._show_package(pkg,INFO_INSTALLED)
             # Get available packages
diff --git a/client/pk-console.c b/client/pk-console.c
index 8d94220..e594e55 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -447,7 +447,7 @@ pk_console_install_package (PkClient *client, const gchar *package)
 {
 	gboolean ret;
 	gchar *package_id;
-	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_AVAILABLE, package);
+	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_NOT_INSTALLED, package);
 	if (package_id == NULL) {
 		g_print ("Could not find a package with that name to install\n");
 		return FALSE;
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index c0b2f01..b44ed0c 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -124,9 +124,9 @@ static PkEnumMatch enum_filter[] = {
 	{PK_FILTER_ENUM_DEVELOPMENT,		"devel"},
 	{PK_FILTER_ENUM_INSTALLED,		"installed"},
 	{PK_FILTER_ENUM_GUI,			"gui"},
-	{PK_FILTER_ENUM_NORMAL,			"~devel"},
-	{PK_FILTER_ENUM_AVAILABLE,		"~installed"},
-	{PK_FILTER_ENUM_TEXT,			"~gui"},
+	{PK_FILTER_ENUM_NOT_DEVELOPMENT,	"~devel"},
+	{PK_FILTER_ENUM_NOT_INSTALLED,		"~installed"},
+	{PK_FILTER_ENUM_NOT_GUI,		"~gui"},
 	{0, NULL},
 };
 
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 4182da6..76fc5fc 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -86,9 +86,9 @@ typedef enum {
 	PK_FILTER_ENUM_DEVELOPMENT,
 	PK_FILTER_ENUM_INSTALLED,
 	PK_FILTER_ENUM_GUI,
-	PK_FILTER_ENUM_NORMAL,		/* not DEVELOPMENT */
-	PK_FILTER_ENUM_AVAILABLE,	/* not INSTALLED */
-	PK_FILTER_ENUM_TEXT,		/* not GUI */
+	PK_FILTER_ENUM_NOT_DEVELOPMENT,
+	PK_FILTER_ENUM_NOT_INSTALLED,
+	PK_FILTER_ENUM_NOT_GUI,
 	PK_FILTER_ENUM_UNKNOWN
 } PkFilterEnum;
 
commit e99a0740044fbbec292a5df2a5bbf77391fbdf71
Author: Tom Parker <palfrey at tevp.net>
Date:   Tue Nov 6 19:49:10 2007 +0100

    Add enums builder for python

diff --git a/Makefile.am b/Makefile.am
index 76d52ab..66129e6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,6 +15,7 @@ SUBDIRS = 						\
 	src						\
 	client						\
 	backends					\
+	python						\
 	$(NULL)
 
 pkgconfigdir = $(libdir)/pkgconfig
@@ -28,6 +29,7 @@ packagekitpython_PYTHON =				\
 	python/packagekit/__init__.py			\
 	python/packagekit/backend.py			\
 	python/packagekit/frontend.py			\
+	python/packagekit/enums.py				\
 	$(NULL)
 	
 
diff --git a/configure.ac b/configure.ac
index 951e858..94d21d6 100755
--- a/configure.ac
+++ b/configure.ac
@@ -463,6 +463,8 @@ libpackagekit/Makefile
 policy/Makefile
 src/Makefile
 client/Makefile
+python/Makefile
+python/packagekit/Makefile
 org.freedesktop.PackageKit.conf
 ])
 
diff --git a/python/Makefile.am b/python/Makefile.am
new file mode 100644
index 0000000..3a5cc46
--- /dev/null
+++ b/python/Makefile.am
@@ -0,0 +1,2 @@
+SUBDIRS = packagekit
+EXTRA_DIST = enum-convertor.py
diff --git a/python/enum-convertor.py b/python/enum-convertor.py
new file mode 100644
index 0000000..42958e2
--- /dev/null
+++ b/python/enum-convertor.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+
+from re import compile,DOTALL,MULTILINE
+
+enum = compile("static PkEnumMatch enum_([^\]]+)\[\] = {(.*?)};", DOTALL|MULTILINE)
+value = compile("PK_([A-Z]+)_ENUM_([A-Z_]+),\s+\"([^\"]+)\"")
+
+inp = open("../libpackagekit/pk-enum.c").read()
+
+names = {}
+
+print "class PackageKitEnum:"
+for (name,data) in enum.findall(inp):
+	print "\t%s = ("%name,
+	for (type,enum,string) in value.findall(data):
+		print "\"%s\","%string,
+		names["%s_%s"%(type,enum)] = string
+	print ")"
+
+print "\n# Constants\n"
+
+for k in sorted(names.keys()):
+	print '%s = "%s"'%(k,names[k])
+
diff --git a/python/packagekit/.gitignore b/python/packagekit/.gitignore
new file mode 100644
index 0000000..afcab3d
--- /dev/null
+++ b/python/packagekit/.gitignore
@@ -0,0 +1,2 @@
+*.pyc
+enums.py
diff --git a/python/packagekit/Makefile.am b/python/packagekit/Makefile.am
new file mode 100644
index 0000000..f31f486
--- /dev/null
+++ b/python/packagekit/Makefile.am
@@ -0,0 +1,4 @@
+BUILT_SOURCES = enums.py
+
+enums.py: ../enum-convertor.py ../../libpackagekit/pk-enum.c
+	(cd ..; python enum-convertor.py > packagekit/enums.py)
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 574097b..14de99a 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -23,91 +23,7 @@
 # imports
 import sys
 import types
-
-
-# Constants
-
-ERROR_OOM = "out-of-memory"
-ERROR_NO_NETWORK = "no-network"
-ERROR_NOT_SUPPORTED = "not-supported"
-ERROR_INTERNAL_ERROR = "internal-error"
-ERROR_GPG_FAILURE = "gpg-failure"
-ERROR_SIGNATURE_NOT_IMPORTED = "signature-not-imported"
-ERROR_PACKAGE_NOT_INSTALLED = "package-not-installed"
-ERROR_PACKAGE_NOT_FOUND = "package-not-found"
-ERROR_PACKAGE_ALREADY_INSTALLED = "package-already-installed"
-ERROR_PACKAGE_DOWNLOAD_FAILED = "package-download-failed"
-ERROR_GROUP_NOT_FOUND = "group-not-found"
-ERROR_DEP_RESOLUTION_FAILED = "dep-resolution-failed"
-ERROR_CREATE_THREAD_FAILED = "create-thread-failed"
-ERROR_FILTER_INVALID = "filter-invalid"
-ERROR_TRANSACTION_ERROR = "transaction-error"
-ERROR_NO_CACHE = "no-cache"
-ERROR_REPO_NOT_FOUND = "repo-not-found"
-ERROR_CANNOT_REMOVE_SYSTEM_PACKAGE = "cannot-remove-system-package"
-ERROR_PROCESS_QUIT="process-quit"
-ERROR_PROCESS_KILL="process-kill"
-ERROR_FAILED_INITIALIZATION="failed-initialization"
-ERROR_FAILED_FINALISE="failed-finalise"
-ERROR_FAILED_CONFIG_PARSING="failed-config-parsing"
-
-STATE_DOWNLOAD = "download"
-STATE_INSTALL = "install"
-STATE_UPDATE = "update"
-STATE_REMOVE = "remove"
-STATE_WAIT = "wait"
-STATE_CLEANUP = "cleanup"
-STATE_OBSOLETE = "obsolete"
-
-RESTART_SYSTEM = "system"
-RESTART_APPLICATION = "application"
-RESTART_SESSION = "session"
-
-INFO_INSTALLED = "installed"
-INFO_AVAILABLE = "available"
-INFO_LOW = "low"
-INFO_NORMAL = "normal"
-INFO_IMPORTANT = "important"
-INFO_SECURITY = "security"
-INFO_DOWNLOADING = "downloading"
-INFO_UPDATING = "updating"
-INFO_INSTALLING = "installing"
-INFO_REMOVING = "removing"
-INFO_CLEANUP = "cleanup"
-INFO_OBSOLETE = "obsoleting"
-
-FILTER_INSTALLED = "installed"
-FILTER_NON_INSTALLED = "~installed"
-FILTER_GUI = "gui"
-FILTER_NON_GUI = "~gui"
-FILTER_DEVEL = "devel"
-FILTER_NON_DEVEL = "~devel"
-
-GROUP_ACCESSIBILITY     = "accessibility"
-GROUP_ACCESSORIES       = "accessories"
-GROUP_EDUCATION         = "education"
-GROUP_GAMES             = "games"
-GROUP_GRAPHICS          = "graphics"
-GROUP_INTERNET          = "internet"
-GROUP_OFFICE            = "office"
-GROUP_OTHER             = "other"
-GROUP_PROGRAMMING       = "programming"
-GROUP_MULTIMEDIA        = "multimedia"
-GROUP_SYSTEM            = "system"
-GROUP_DESKTOP_GNOME     = "desktop-gnome"
-GROUP_DESKTOP_KDE       = "desktop-kde"
-GROUP_DESKTOP_XFCE      = "desktop-xfce"
-GROUP_DESKTOP_OTHER     = "desktop-other"
-GROUP_PUBLISHING        = "publishing"
-GROUP_SERVERS           = "servers"
-GROUP_FONTS             = "fonts"
-GROUP_ADMIN_TOOLS       = "admin-tools"
-GROUP_LEGACY            = "legacy"
-GROUP_LOCALIZATION      = "localization"
-GROUP_VIRTUALIZATION    = "virtualization"
-GROUP_SECURITY          = "security"
-GROUP_POWER_MANAGEMENT  = "power-management"
-GROUP_UNKNOWN           = "unknown"
+from enums import *
 
 # Classes
 
diff --git a/python/packagekit/frontend.py b/python/packagekit/frontend.py
index f35d65a..b5f4bff 100644
--- a/python/packagekit/frontend.py
+++ b/python/packagekit/frontend.py
@@ -23,6 +23,7 @@ from types import *
 import dbus
 from dbus.mainloop.glib import DBusGMainLoop
 import gobject
+from enums import PackageKitEnum
 
 class PackageKitException(Exception):
 	def __init__(self):
commit a2ccaf90927920910644788d81cdda2834837a2d
Author: Tom Parker <palfrey at tevp.net>
Date:   Tue Nov 6 16:11:23 2007 +0100

    Update python interface to new API

diff --git a/python/packagekit/frontend.py b/python/packagekit/frontend.py
index 154e1fd..f35d65a 100644
--- a/python/packagekit/frontend.py
+++ b/python/packagekit/frontend.py
@@ -99,7 +99,6 @@ class PackageKit:
 				raise PackageKitException(e)
 
 		#self.job = None
-		self.progress = 0.0
 		bus.add_signal_receiver(self.catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member',dbus_interface="org.freedesktop.PackageKit")
 
 	def run(self):
@@ -107,18 +106,11 @@ class PackageKit:
 		self.loop.run()
 
 	def catchall_signal_handler(self,*args, **kwargs):
-		#if args[0] != self.job and kwargs['member']!="TransactionListChanged":
-		#	print "args",args,kwargs
-		#	return
 		if kwargs['member'] == "Finished":
 			self.loop.quit()
 			self.Finished(args[0],args[1],args[2])
-		elif kwargs['member'] == "PercentageChanged":
-			self.progress = float(args[1])+(self.progress%1.0)
-			self.Percentage(args[0], self.progress)
-		elif kwargs['member'] == "SubPercentageChanged":
-			self.progress = (float(args[1])/100.0)+int(self.progress)
-			self.Percentage(args[0], self.progress)
+		elif kwargs['member'] == "ProgressChanged":
+			self.ProgressChanged(args[0], float(args[1])+(float(args[2])/100.0),args[3],args[4])
 		elif kwargs['member'] == "TransactionStatusChanged":
 			self.JobStatus(args[0], args[1])
 		elif kwargs['member'] == "Package":
@@ -133,7 +125,7 @@ class PackageKit:
 			self.RequireRestart(args[0],args[1],args[2])
 		elif kwargs['member'] == "Transaction":
 			self.Transaction(args[0],args[1],args[2],args[3],args[4],args[5])
-		elif kwargs['member'] in ["NoPercentageUpdates","TransactionListChanged",
+		elif kwargs['member'] in ["TransactionListChanged",
 					  "AllowInterrupt","JobListChanged", "Locked"]:
 			pass
 		else:
diff --git a/python/pk-frontend-test.py b/python/pk-frontend-test.py
index c0c5356..25bd613 100755
--- a/python/pk-frontend-test.py
+++ b/python/pk-frontend-test.py
@@ -30,8 +30,8 @@ from types import FunctionType
 from packagekit.frontend import *
 
 class pkt(PackageKit):
-	def Percentage(self,jid,progress):
-		print "Progress: %.2f%%"%progress
+	def ProgressChanged(self,jid,percent, elapsed, remaining):
+		print "Progress: %.2f%%"%percent, elapsed, remaining
 
 	def JobStatus(self,jid,type):
 		print "Job type: %s"%type
commit e09f72e214f036ea1e9b0cdfeb51f2f6374024db
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Nov 5 23:43:53 2007 +0000

    fix make check

diff --git a/html/img/Makefile.am b/html/img/Makefile.am
index 062e23d..cd866b1 100644
--- a/html/img/Makefile.am
+++ b/html/img/Makefile.am
@@ -9,7 +9,8 @@ IMAGE_FILES =					\
 	large-preferences-system.png		\
 	large-system-users.png			\
 	packagekit.png				\
-	pk-application.png			\
+	pk-application-search.png		\
+	pk-application-groups.png		\
 	pk-auto-update.png			\
 	pk-backend-status.png			\
 	pk-battery.png				\



More information about the PackageKit mailing list