def _on_lowlevel_transactions_changed(self, watcher, current, pending):
# cleanup progress signal (to be sure to not leave dbus
# matchers around)
if self._progress_signal:
GObject.source_remove(self._progress_signal)
self._progress_signal = None
# attach progress-changed signal for current transaction
if current:
try:
trans = client.get_transaction(current)
self._progress_signal = trans.connect("progress-changed",
self._on_progress_changed)
except dbus.DBusException:
pass
# now update pending transactions
self.pending_transactions.clear()
for tid in [current] + pending:
if not tid:
continue
try:
trans = client.get_transaction(tid,
error_handler=lambda x: True)
except dbus.DBusException:
continue
trans_progress = TransactionProgress(trans)
try:
self.pending_transactions[trans_progress.pkgname] = \
trans_progress
except KeyError:
# if its not a transaction from us (sc_pkgname) still
# add it with the tid as key to get accurate results
# (the key of pending_transactions is never directly
# exposed in the UI)
self.pending_transactions[trans.tid] = trans_progress
# emit signal
self.inject_fake_transactions_and_emit_changed_signal()
评论列表
文章目录