commit d8c13d8c3e875bf1d87650646cb960a87468ba87 Author: Fabio Erculiani Date: Wed Oct 5 22:39:30 2011 +0200 entropy: add forward compatibility with upcoming API changes diff --git a/backends/entropy/entropyBackend.py b/backends/entropy/entropyBackend.py index fe8c609..0c82039 100755 --- a/backends/entropy/entropyBackend.py +++ b/backends/entropy/entropyBackend.py @@ -64,7 +64,8 @@ from entropy.client.interfaces import Client from entropy.core.settings.base import SystemSettings from entropy.misc import LogFile from entropy.cache import EntropyCacher -from entropy.exceptions import SystemDatabaseError +from entropy.exceptions import SystemDatabaseError, DependenciesNotFound, \ + DependenciesCollision from entropy.db.exceptions import Error as EntropyRepositoryError try: from entropy.exceptions import DependenciesNotRemovable @@ -589,18 +590,32 @@ class PackageKitEntropyMixin(object): if calculate_deps: self.status(STATUS_DEP_RESOLVE) empty_deps, deep_deps = False, False - run_queue, removal_queue, status = self._entropy.get_install_queue( - matches, empty_deps, deep_deps) + try: + queue_obj = self._entropy.get_install_queue( + matches, empty_deps, deep_deps) + if len(queue_obj) == 2: + # new api + run_queue, removal_queue = queue_obj + else: + # old api + run_queue, removal_queue, status = queue_obj + if status == -2: + raise DependenciesNotFound(run_queue) + elif status == -3: + raise DependenciesCollision(run_queue) + except DependenciesNotFound as exc: + self.error(ERROR_DEP_RESOLUTION_FAILED, + "Cannot find the following dependencies: %s" % ( + ', '.join(sorted(exc.value)),)) + return + except DependenciesCollision: + self.error(ERROR_DEP_RESOLUTION_FAILED, + "Dependencies collisions, cannot continue") + return + else: run_queue = matches removal_queue = [] - status = 0 - - if status == -2: - self.error(ERROR_DEP_RESOLUTION_FAILED, - "Cannot find the following dependencies: %s" % ( - ', '.join(run_queue),)) - return self.percentage(0) self.status(STATUS_DOWNLOAD) @@ -934,12 +949,26 @@ class PackageKitEntropyBackend(PackageKitBaseBackend, PackageKitEntropyMixin): empty = False deep = False - install, removal, deps_not_f = self._entropy.get_install_queue(matches, - empty, deep, recursive = recursive) - - if deps_not_f == -2: + try: + queue_obj = self._entropy.get_install_queue(matches, + empty, deep, recursive = recursive) + if len(queue_obj) == 2: + # new api + install, removal = queue_obj + else: + # old api + install, removal, status = queue_obj + if status == -2: + raise DependenciesNotFound(install) + elif status == -3: + raise DependenciesCollision(install) + except DependenciesNotFound as exc: + self.error(ERROR_DEP_RESOLUTION_FAILED, + "Dependencies not found: %s" % (sorted(exc.value),)) + return + except DependenciesCollision: self.error(ERROR_DEP_RESOLUTION_FAILED, - "Dependencies not found: %s" % (sorted(install),)) + "Dependencies collisions, cannot continue") return # transform install into (repo, pkg_id, c_repo) list