Skip to content

Commit

Permalink
Added signal transactionelemproceAdded management
Browse files Browse the repository at this point in the history
  • Loading branch information
anaselli committed Dec 30, 2024
1 parent 9e3ab8b commit bb1e31f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif(POLICY CMP0048)

project(dnfdragora VERSION 2.99.0 LANGUAGES NONE)
project(dnfdragora VERSION 2.99.1 LANGUAGES NONE)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

Expand Down
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
202X-XX-XX v. 2.99.1
--------------------
- Added signal transactionelemprocess

2024-12-29 v. 2.99.0
--------------------
- Port to dnf5daemon
Expand Down
22 changes: 22 additions & 0 deletions dnfdragora/dnfd_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ def _get_daemon(self):

self.iface_rpm.connect_to_signal("transaction_before_begin", self.on_TransactionBeforeBegin)

self.iface_rpm.connect_to_signal("transaction_elem_progress", self.on_TransactionElemProgress)

self.iface_rpm.connect_to_signal("transaction_verify_start", self.on_TransactionVerifyStart)
self.iface_rpm.connect_to_signal("transaction_verify_progress", self.on_TransactionVerifyProgress)
self.iface_rpm.connect_to_signal("transaction_verify_stop", self.on_TransactionVerifyStop)
Expand Down Expand Up @@ -699,6 +701,26 @@ def on_TransactionBeforeBegin(self, *args) :
# Start the transaction timer
self.__TransactionTimer.start()

def on_TransactionElemProgress(self, session_object_path, nevra, processed, total):
"""
Overall progress in transaction item processing. Called right before an item is processed.
Args:
@session_object_path: object path of the dnf5daemon session
@nevra: full NEVRA of the package
@processed: amount already processed (starting from 0, just before it is processed)
@total: total to process
"""
# Start the transaction timer
self.__TransactionTimer.start()
self.eventQueue.put({'event': 'OnTransactionElemProgress',
'value': {
'session_object_path': unpack_dbus(session_object_path),
'nevra': unpack_dbus(nevra),
'processed': unpack_dbus(processed),
'total': unpack_dbus(total),
}
})

def on_TransactionAfterComplete(self, session_object_path, success) :
'''
Sent right after the rpm transaction run finished.
Expand Down
20 changes: 20 additions & 0 deletions dnfdragora/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,24 @@ def _OnTransactionActionStop(self, session_object_path, nevra, total):
return
self.infobar.reset_all()

def _OnTransactionElemProgress(self, session_object_path, nevra, processed, total):
"""
Overall progress in transaction item processing. Called right before an item is processed.
Args:
@session_object_path: object path of the dnf5daemon session
@nevra: full NEVRA of the package
@processed: amount already processed (starting from 0, just before it is processed)
@total: total to process
"""
values = (session_object_path, nevra, total)
logger.debug('OnTransactionElemProgress: %s', repr(values))
if session_object_path != self.backend.session_path :
logger.warning("OnTransactionElemProgress: Different session path received")
return
total_frac = (processed+1) / total if total > 0 else 0
self.infobar.set_progress(total_frac)
self.infobar.info( _('Transaction in progress: <%(nevra)s> starts') %{'nevra': nevra, })

def _OnTransactionTransactionStart(self, session_object_path, total):
'''
Preparation of transaction packages has started.
Expand Down Expand Up @@ -2521,6 +2539,8 @@ def _manageDnfDaemonEvent(self):
self._OnTransactionActionProgress(info['session_object_path'], info['nevra'], info['processed'], info['total'])
elif (event == 'OnTransactionActionStop'):
self._OnTransactionActionStop(info['session_object_path'], info['nevra'], info['total'])
elif (event == 'OnTransactionElemProgress'):
self._OnTransactionElemProgress(info['session_object_path'], info['nevra'], info['processed'], info['total'])
elif (event == 'OnTransactionTransactionStart'):
self._OnTransactionTransactionStart(info['session_object_path'], info['total'])
elif (event == 'OnTransactionTransactionProgress'):
Expand Down

0 comments on commit bb1e31f

Please sign in to comment.