Skip to content

Commit

Permalink
Added transaction transaction signals handling
Browse files Browse the repository at this point in the history
  • Loading branch information
anaselli committed Sep 15, 2024
1 parent db2263f commit bb79b9d
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 25 deletions.
47 changes: 22 additions & 25 deletions dnfdragora/dnfd_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,25 +773,24 @@ def on_TransactionActionStop(self, session_object_path, nevra, total):
}
})

def on_TransactionTransactionStart(self, *args):
def on_TransactionTransactionStart(self, session_object_path, total):
'''
Preparation of transaction packages has started.
Manages the transaction_transaction_start signal.
Args:
@session_object_path: object path of the dnf5daemon session
@total: total to process
'''
logger.debug("on_TransactionTransactionStart (%s)", repr(args))
# Refresh the transaction timeout
self.__TransactionTimer.start()
#self.eventQueue.put({'event': 'OnTransactionTransactionStart',
# 'value': {
# 'session_object_path': unpack_dbus(session_object_path),
# 'total': unpack_dbus(total),
# }
# })
self.eventQueue.put({'event': 'OnTransactionTransactionStart',
'value': {
'session_object_path': unpack_dbus(session_object_path),
'total': unpack_dbus(total),
}
})

def on_TransactionTransactionProgress(self, *args):
def on_TransactionTransactionProgress(self, session_object_path, processed, total):
'''
Progress in preparation of transaction packages.
Manages the transaction_transaction_progress signal.
Expand All @@ -800,34 +799,32 @@ def on_TransactionTransactionProgress(self, *args):
@processed: amount already processed
@total: total to process
'''
logger.debug("on_TransactionTransactionProgress (%s)", repr(args))
# Refresh the transaction timeout
self.__TransactionTimer.start()
#self.eventQueue.put({'event': 'OnTransactionTransactionProgress',
# 'value': {
# 'session_object_path': unpack_dbus(session_object_path),
# 'processed': unpack_dbus(processed),
# 'total': unpack_dbus(total),
# }
# })
self.eventQueue.put({'event': 'OnTransactionTransactionProgress',
'value': {
'session_object_path': unpack_dbus(session_object_path),
'processed': unpack_dbus(processed),
'total': unpack_dbus(total),
}
})

def on_TransactionTransactionStop(self, *args):
def on_TransactionTransactionStop(self, session_object_path, total):
'''
Preparation of transaction packages has finished.
Manages thetransaction_transaction_stop signal.
Args:
@session_object_path: object path of the dnf5daemon session
@total: total to process
'''
logger.debug("on_TransactionTransactionStop (%s)", repr(args))
# Refresh the transaction timeout
self.__TransactionTimer.start()
#self.eventQueue.put({'event': 'OnTransactionTransactionStop',
# 'value': {
# 'session_object_path': unpack_dbus(session_object_path),
# 'total': unpack_dbus(total),
# }
# })
self.eventQueue.put({'event': 'OnTransactionTransactionStop',
'value': {
'session_object_path': unpack_dbus(session_object_path),
'total': unpack_dbus(total),
}
})

#def on_TransactionScriptStart(self, nevra, *args):
def on_TransactionScriptStart(self, *args):
Expand Down
57 changes: 57 additions & 0 deletions dnfdragora/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,57 @@ def _OnTransactionActionStop(self, session_object_path, nevra, total):
return
self.infobar.reset_all()

def _OnTransactionTransactionStart(self, session_object_path, total):
'''
Preparation of transaction packages has started.
Manages the transaction_transaction_start signal.
Args:
@session_object_path: object path of the dnf5daemon session
@total: total to process
'''
values = (session_object_path, total)
logger.debug('OnTransactionTransactionStart: %s', repr(values))
if session_object_path != self.backend.session_path :
logger.warning("OnTransactionTransactionStart: Different session path received")
return
self.infobar.set_progress(0.0)
self.infobar.info( _('Preparation of transaction'))

def _OnTransactionTransactionProgress(self, session_object_path, processed, total):
'''
Progress in preparation of transaction packages.
Manages the transaction_transaction_progress signal.
Args:
@session_object_path: object path of the dnf5daemon session
@processed: amount already processed
@total: total to process
'''
values = (session_object_path, processed, total)
logger.debug('OnTransactionTransactionProgress: %s', repr(values))
if session_object_path != self.backend.session_path :
logger.warning("OnTransactionTransactionProgress: Different session path received")
return
total_frac = processed / total if total > 0 else 0
self.infobar.set_progress(total_frac)
self.infobar.info( _('Preparation of transaction'))


def _OnTransactionTransactionStop(self, session_object_path, total):
'''
Preparation of transaction packages has finished.
Manages thetransaction_transaction_stop signal.
Args:
@session_object_path: object path of the dnf5daemon session
@total: total to process
'''
values = (session_object_path, total)
logger.debug('OnTransactionTransactionStop: %s', repr(values))
if session_object_path != self.backend.session_path :
logger.warning("OnTransactionTransactionStop: Different session path received")
return
self.infobar.reset_all()


def __addDownload(self, download_id, description, total_to_download):
'''
add new download events
Expand Down Expand Up @@ -2376,6 +2427,12 @@ 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 == 'OnTransactionTransactionStart'):
self._OnTransactionTransactionStart(info['session_object_path'], info['total'])
elif (event == 'OnTransactionTransactionProgress'):
self._OnTransactionTransactionProgress(info['session_object_path'], info['processed'], info['total'])
elif (event == 'OnTransactionTransactionStop'):
self._OnTransactionTransactionStop(info['session_object_path'], info['total'])
elif (event == 'OnTransactionScriptStart') or \
(event == 'OnTransactionScriptStop') or \
(event == 'OnTransactionScriptError') or \
Expand Down

0 comments on commit bb79b9d

Please sign in to comment.