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

Richard Hughes hughsient at kemper.freedesktop.org
Mon Oct 1 12:56:56 PDT 2007


 TODO                                     |    3 
 backends/conary/helpers/conaryBackend.py |   67 --------
 python/packagekit/frontend.py            |  252 ++++++++++++++++++++++++++++++-
 python/pk-frontend-test.py               |   13 +
 4 files changed, 265 insertions(+), 70 deletions(-)

New commits:
diff-tree 48297dbb9e4af55686af6ccd272a441b035fa5f2 (from a21422005fa99b60e8f8d33c0075c4cbcdbbb981)
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Oct 1 20:13:08 2007 +0100

    update TODO

diff --git a/TODO b/TODO
index 3f4b12c..f5a2387 100644
--- a/TODO
+++ b/TODO
@@ -36,9 +36,6 @@ to expose in the UI.
 Client programs using libpackagekit should know the error, rather than just
 "it failed"
 
-*** Log what was installed/removed and when ***
-Need to monitor the Package's emitted by the task and encoded to a string
-
 *** Handle rollbacks for select backends ***
 To do rollbacks sanely in PK we need a few things:
  * emit internal signal for SetTransactionData
diff-tree a21422005fa99b60e8f8d33c0075c4cbcdbbb981 (from f5432fe0048a6edffd53536a420f5a76650d707f)
Author: Ken VanDine <ken at vandine.org>
Date:   Mon Oct 1 14:49:23 2007 -0400

    More fixes for the new enum installed status

diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 512f46e..8543d8c 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -173,7 +173,7 @@ class PackageKitConaryBackend(PackageKit
         name, version, flavor, installed = self._findPackage(package_id)
 
         if name:
-            if installed:
+            if installed == INFO_INSTALLED:
                 self.error(ERROR_PACKAGE_ALREADY_INSTALLED,
                     'Package already installed')
             try:
@@ -192,7 +192,7 @@ class PackageKitConaryBackend(PackageKit
         name, version, flavor, installed = self._findPackage(package_id)
 
         if name:
-            if not installed:
+            if not installed == INFO_INSTALLED:
                 self.error(ERROR_PACKAGE_NOT_INSTALLED,
                     'Package not installed')
             try:
@@ -278,9 +278,9 @@ class PackageKitConaryBackend(PackageKit
         do_print = False;
         if filterList == ['none']: # 'none' = all packages.
             return True
-        elif 'installed' in filterList and installed == 1:
+        elif 'installed' in filterList and installed == INFO_INSTALLED:
             do_print = True
-        elif '~installed' in filterList and installed == 0:
+        elif '~installed' in filterList and installed == INFO_AVAILABLE:
             do_print = True
 
         if len(filterList) == 1: # Only one filter, return
diff-tree f5432fe0048a6edffd53536a420f5a76650d707f (from ab844c1dd98fbb7c9bd8bd2abcd2b7983b4dca7a)
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Mon Oct 1 14:26:43 2007 -0400

    Add all of the existing methods an signal handlers to frontend.py
    Generated from pk-interface.xml, but most calls seem to work.

diff --git a/python/packagekit/frontend.py b/python/packagekit/frontend.py
index f38d7e8..1ee56f9 100644
--- a/python/packagekit/frontend.py
+++ b/python/packagekit/frontend.py
@@ -214,24 +214,272 @@ class PackageKit:
 
 
 # --- PK Methods ---
+
+## Start a new transaction to do Foo
 	
 	@dbusException
 	@job_id
+	def GetUpdates(self):
+		"""
+		Lists packages which could be updated.
+		Causes 'Package' signals for each available package.
+		"""
+		return self.pk_iface.GetUpdates(self.tid())
+
+	@dbusException
+	@job_id
+	def RefreshCache(self,force=False):
+		"""
+		Refreshes the backend's cache.
+		"""
+		return self.pk_iface.RefreshCache(self.tid(),force)
+
+	@dbusException
+	@job_id
+	def UpdateSystem(self):
+		"""
+		Applies all available updates.
+		Asynchronous
+		"""
+		return self.pk_iface.UpdateSystem(self.tid())
+
+	@dbusException
+	@job_id
+	def Resolve(self,package_id):
+		"""
+		Resolves dependancies.
+		(description is a guess, since this not yet supported in yum backend, and maybe others)
+		"""
+		return self.pk_iface.Resolve(self.tid(),package_id)
+
+	@dbusException
+	@job_id
 	def SearchName(self,pattern,filter="none"):
+		"""
+		Searches the 'Name' field for something matching 'pattern'.
+		'filter' could be 'installed', a repository name, or 'none'.
+		Causes 'Package' signals for each package found.
+		"""
 		return self.pk_iface.SearchName(self.tid(),filter,pattern)
 
 	@dbusException
 	@job_id
+	def SearchDetails(self,pattern,filter="none"):
+		"""
+		Searches the 'Details' field for something matching 'pattern'.
+		'filter' could be 'installed', a repository name, or 'none'.
+		Causes 'Package' signals for each package found.
+		"""
+		return self.pk_iface.SearchDetails(self.tid(),filter,pattern)
+
+	@dbusException
+	@job_id
+	def SearchGroup(self,pattern,filter="none"):
+		"""
+		Lists all packages in groups matching 'pattern'.
+		'filter' could be 'installed', a repository name, or 'none'.
+		Causes 'Package' signals for each package found.
+		(description is a guess, since this not yet supported in yum backend, and maybe others)
+		"""
+		return self.pk_iface.SearchGroup(self.tid(),filter,pattern)
+
+	@dbusException
+	@job_id
+	def SearchFile(self,pattern,filter="none"):
+		"""
+		Lists all packages that provide a file matching 'pattern'.
+		'filter' could be 'installed', a repository name, or 'none'.
+		Causes 'Package' signals for each package found.
+		"""
+		return self.pk_iface.SearchFile(self.tid(),filter,pattern)
+
+	@dbusException
+	@job_id
+	def GetDepends(self,package_id):
+		"""
+		Lists package dependancies?
+		(description is a guess, since this doesn't seem to work for me)
+		"""
+		return self.pk_iface.GetDepends(self.tid(),package_id)
+
+	@dbusException
+	@job_id
+	def GetRequires(self,package_id):
+		"""
+		Lists package dependancies?
+		(description is a guess, since this not doesn't seem to work for me)
+		"""
+		return self.pk_iface.GetRequires(self.tid(),package_id)
+
+	@dbusException
+	@job_id
+	def GetUpdateDetail(self,package_id):
+		"""
+		More details about an update.
+		(description is a guess, since this not yet supported in yum backend, and maybe others)
+		"""
+		return self.pk_iface.GetUpdateDetail(self.tid(),package_id)
+
+	@dbusException
+	@job_id
 	def GetDescription(self,package_id):
+		"""
+		Gets the Description of a given package_id.
+		Causes a 'Description' signal.
+		"""
 		return self.pk_iface.GetDescription(self.tid(),package_id)
 
 	@dbusException
 	@job_id
-	def RefreshCache(self,force=False):
-		return self.pk_iface.RefreshCache(self.tid(),force)
+	def RemovePackage(self,package_id,allow_deps=False ):
+		"""
+		Removes a package.
+		Asynchronous
+		"""
+		return self.pk_iface.RemovePackage(self.tid(),package_id,allow_deps)
+
+	@dbusException
+	@job_id
+	def InstallPackage(self,package_id):
+		"""
+		Installs a package.
+		Asynchronous
+		"""
+		return self.pk_iface.InstallPackage(self.tid(),package_id)
+
+	@dbusException
+	@job_id
+	def UpdatePackage(self,package_id):
+		"""
+		Updates a package.
+		Asynchronous
+		"""
+		return self.pk_iface.UpdatePackage(self.tid(),package_id)
+
+	@dbusException
+	@job_id
+	def InstallFile(self,full_path):
+		"""
+		Installs a package which provides given file?
+		Asynchronous
+		"""
+		return self.pk_iface.InstallFile(self.tid(),full_path)
+
+## Do things or query transactions
+	@dbusException
+	@job_id
+	def Cancel(self):
+		"""
+		Might not succeed for all manner or reasons.
+		throws NoSuchTransaction
+		"""
+		return self.pk_iface.Cancel(self.tid())
+
+	@dbusException
+	@job_id
+	def GetStatus(self):
+		"""
+		This is what the transaction is currrently doing, and might change.
+		Returns status (query,download,install,exit)
+		throws NoSuchTransaction
+		"""
+		return self.pk_iface.GetStatus(self.tid())
+
+	@dbusException
+	@job_id
+	def GetRole(self):
+		"""
+		This is the master role, i.e. won't change for the lifetime of the transaction
+		Returns status (query,download,install,exit) and package_id (package acted upon, or NULL
+		throws NoSuchTransaction
+		"""
+		return self.pk_iface.GetRole(self.tid())
+
+	@dbusException
+	@job_id
+	def GetPercentage(self):
+		"""
+		Returns percentage of transaction complete
+		throws NoSuchTransaction
+		"""
+		return self.pk_iface.GetPercentage(self.tid())
+
+	@dbusException
+	@job_id
+	def GetSubPercentage(self):
+		"""
+		Returns percentage of this part of transaction complete
+		throws NoSuchTransaction
+		"""
+		return self.pk_iface.GetSubPercentage(self.tid())
+
+	@dbusException
+	@job_id
+	def GetPackage(self):
+		"""
+		Returns package being acted upon at this very moment
+		throws NoSuchTransaction
+		"""
+		return self.pk_iface.GetPackage(self.tid())
+
+## Get lists of transactions
+
+	@dbusException
+	def GetTransactionList(self):
+		"""
+		Returns list of (active) transactions.
+		"""
+		return self.pk_iface.GetTransactionList()
 
 	@dbusException
 	@job_id
 	def GetOldTransactions(self,number=5):
+		"""
+		Causes Transaction signals for each Old transaction.
+		"""
 		return self.pk_iface.GetOldTransactions(self.tid(),number)
 
+## General methods
+
+	@dbusException
+	def GetBackendDetail(self):
+		"""
+		Returns name, author, and version of backend.
+		"""
+		return self.pk_iface.GetBackendDetail()
+
+	@dbusException
+	def GetActions(self):
+		"""
+		Returns list of supported actions.
+		"""
+		return self.pk_iface.GetActions()
+
+	@dbusException
+	def GetGroups(self):
+		"""
+		Returns list of supported groups.
+		"""
+		return self.pk_iface.GetGroups()
+
+	@dbusException
+	def GetFilters(self):
+		"""
+		Returns list of supported filters.
+		"""
+		return self.pk_iface.GetFilters()
+
+
+class DumpingPackageKit(PackageKit):
+	"""
+	Just like PackageKit(), but prints all signals instead of handling them
+	"""
+	def catchall_signal_handler(self,*args, **kwargs):
+		if kwargs['member'] == "Finished":
+			self.loop.quit()
+
+		print "Caught signal %s"% kwargs['member']
+		print "  args:"
+		for arg in args:
+			print "		" + str(arg)
+	
diff --git a/python/pk-frontend-test.py b/python/pk-frontend-test.py
index c64a350..8f8eb25 100755
--- a/python/pk-frontend-test.py
+++ b/python/pk-frontend-test.py
@@ -64,7 +64,7 @@ def desc(*args):
 		raise PackageKitTransactionFailure
 	return p.GetDescription(args[0][0])
 
-def refresh_cache(args):
+def refresh_cache(*args):
 	if len(args)>0 and len(args[0])>0:
 		print "refresh_cache doesn't take args"
 		raise PackageKitTransactionFailure
@@ -82,6 +82,15 @@ def history(*args):
 
 	return p.GetOldTransactions(count)
 
+def get_backend_detail(*args):
+	details = p.GetBackendDetail()
+	for d in details:
+		print "  %s" % d
+
+	# Quit immediately because no job was scheduled
+	exit(0)
+
+
 def usage():
 	print "Usage: %s <command> <options>"%argv[0]
 	print "Valid commands are:"
@@ -104,7 +113,7 @@ if not globals().has_key(args[0]):
 	usage()
 
 try:
-	job = globals()[args[0]](args[1:])
+	globals()[args[0]](args[1:])
 except PackageKitAccessDenied:
 	print "You don't have sufficient permissions to access PackageKit (on the org.freedesktop.PackageKit dbus service)"
 	exit(1)
diff-tree ab844c1dd98fbb7c9bd8bd2abcd2b7983b4dca7a (from 0b860848bc7253bf30eaac526e6b8110b586d783)
Author: Ken VanDine <ken at vandine.org>
Date:   Mon Oct 1 13:41:16 2007 -0400

    Removed live search

diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index b71771e..512f46e 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -99,59 +99,6 @@ class PackageKitConaryBackend(PackageKit
                 id = self.get_package_id(name, version, flavor)
                 self.package(id, installed, summary)
 
-    def _do_search_live(self, searchlist, filters):
-        '''
-        Search for conary packages
-        @param searchlist: The conary package fields to search in
-        @param options: package types to search (all,installed,available)
-        '''
-        repos = self.client.getRepos()
-        db = conaryclient.ConaryClient(self.cfg).db
-        affinityDb = self.client.db
-        fltlist = filters.split(';')
-
-        troveSpecs = [ updatecmd.parseTroveSpec(searchlist,
-                                                allowEmptyName=False) ]
-
-        try:
-            # Look for packages with affinity
-            troveTupleList = queryrep.getTrovesToDisplay(repos, troveSpecs,
-                None, None, queryrep.VERSION_FILTER_LATEST,
-                queryrep.FLAVOR_FILTER_BEST, self.cfg.installLabelPath,
-                self.cfg.flavor, affinityDb)
-            # Look for packages regardless of affinity
-            troveTupleList.extend(queryrep.getTrovesToDisplay(repos, troveSpecs,
-                None, None, queryrep.VERSION_FILTER_LATEST,
-                queryrep.FLAVOR_FILTER_BEST, self.cfg.installLabelPath,
-                self.cfg.flavor, None))
-            # Remove dupes
-            tempDict = {}
-            try:
-                for element in troveTupleList:
-                    tempDict[element] = None
-            except TypeError:
-                del tempDict  # move on to the next method
-            else:
-                troveTupleList = tempDict.keys()
-
-            # Get the latest first
-            troveTupleList.sort()
-            troveTupleList.reverse()
-
-            for troveTuple in troveTupleList:
-                name = troveTuple[0]
-                version = troveTuple[1]
-                flavor = troveTuple[2]
-                # We don't have summary data yet... so leave it blank for now
-                summary = " "
-                installed = self.check_installed(troveTuple)
-
-                if self._do_filtering(name,fltlist,installed):
-                    id = self.get_package_id(name, version, flavor)
-                    self.package(id, installed, summary)
-        except:
-            self.error(ERROR_INTERNAL_ERROR, 'An internal error has occurred')
-
     def _do_update(self, applyList, apply=False):
         updJob = self.client.newUpdateJob()
         suggMap = self.client.prepareUpdateJob(updJob, applyList)
@@ -185,12 +132,6 @@ class PackageKitConaryBackend(PackageKit
         '''
         self._do_search(searchlist, options)
 
-    def search_name_live(self, options, searchlist):
-        '''
-        Implement the {backend}-search-name-live functionality
-        '''
-        self._do_search_live(searchlist, options)
-
     def search_details(self, opt, key):
         pass
 



More information about the PackageKit mailing list