summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2013-06-13 17:37:12 -0400
committerCole Robinson <crobinso@redhat.com>2013-06-13 17:37:12 -0400
commit8a0bee44dceabb6bc42681f647ae98e35c1b9a8a (patch)
treee629238f3a5ea1789d5c2832547d21713a4a68f0
parent1c22ea92dff3e1d652ef3149b23e90f60d8d96e1 (diff)
downloadvirt-manager-8a0bee44dceabb6bc42681f647ae98e35c1b9a8a.tar.gz
packagekit: Allow cancelling package search
-rw-r--r--virtManager/packageutils.py31
1 files changed, 21 insertions, 10 deletions
diff --git a/virtManager/packageutils.py b/virtManager/packageutils.py
index 39f5c663..8b2b1ac0 100644
--- a/virtManager/packageutils.py
+++ b/virtManager/packageutils.py
@@ -59,10 +59,11 @@ def check_packagekit(errbox, packages, ishv):
else:
msg = _("Checking for installed package '%s'") % packages[0]
- found = []
+ cancellable = Gio.Cancellable()
progWin = vmmAsyncJob(_do_async_search,
- [bus, pk_control, packages], msg, msg,
- errbox.get_parent(), async=False)
+ [bus, pk_control, packages, cancellable], msg, msg,
+ errbox.get_parent(), async=False,
+ cancel_cb=[_cancel_search, cancellable])
error, ignore = progWin.run()
if error:
return
@@ -109,16 +110,25 @@ def check_packagekit(errbox, packages, ishv):
return do_install
-def _do_async_search(asyncjob, bus, pk_control, packages):
+def _cancel_search(asyncjob, cancellable):
+ cancellable.cancel()
+ asyncjob.job_cancelled = True
+
+
+def _do_async_search(asyncjob, bus, pk_control, packages, cancellable):
found = []
try:
for name in packages:
- ret_found = packagekit_search(bus, pk_control, name, packages)
+ ret_found = packagekit_search(bus, pk_control, name, packages,
+ cancellable)
found += ret_found
-
except Exception, e:
- logging.exception("Error searching for installed packages")
- asyncjob.set_error(str(e), "".join(traceback.format_exc()))
+ if cancellable.is_cancelled():
+ logging.debug("Package search cancelled by user")
+ asyncjob.set_error("Package search cancelled by user")
+ else:
+ logging.exception("Error searching for installed packages")
+ asyncjob.set_error(str(e), "".join(traceback.format_exc()))
asyncjob.set_extra_data(found)
@@ -138,11 +148,12 @@ def packagekit_install(package_list):
timeout=timeout)
-def packagekit_search(bus, pk_control, package_name, packages):
+def packagekit_search(bus, pk_control, package_name, packages, cancellable):
tid = pk_control.CreateTransaction()
pk_trans = Gio.DBusProxy.new_sync(bus, 0, None,
"org.freedesktop.PackageKit", tid,
- "org.freedesktop.PackageKit.Transaction", None)
+ "org.freedesktop.PackageKit.Transaction",
+ cancellable)
found = []
def package(info, package_id, summary):