def __init__(self, db, post_message): self.data = None self.loop = None self.post_message = post_message self.transaction = self.transaction = Pamac.Transaction(database=db) self.transaction.connect("emit-action", self.on_emit_action, self.data) self.transaction.connect("emit-action-progress", self.on_emit_action_progress, self.data) self.transaction.connect("emit-hook-progress", self.on_emit_hook_progress, self.data) self.transaction.connect("emit-error", self.on_emit_error, self.data) self.transaction.connect("emit-warning", self.on_emit_warning, self.data) self.transaction.connect("finished", self.on_trans_finished, self.data)
print("Error: ", e.message) else: print("Success :", success) finally: loop.quit() transaction.quit_daemon() def run_transaction(): # /!\ the transaction will run without confirmation /!\ # you need to override Transaction.ask_confirmation() method # in order to implement your own confirmation step transaction.add_pkg_to_install("pkgname") transaction.run_async(on_transaction_finished_callback, None) # launch a loop to wait for the callback to be called loop.run() if __name__ == "__main__": loop = GLib.MainLoop() config = Pamac.Config(conf_path="/etc/pamac.conf") db = Pamac.Database(config=config) transaction = Pamac.Transaction(database=db) data = None transaction.connect("emit-action", on_emit_action, data) transaction.connect("emit-action-progress", on_emit_action_progress, data) transaction.connect("emit-hook-progress", on_emit_hook_progress, data) transaction.connect("emit-error", on_emit_error, data) transaction.connect("emit-warning", on_emit_warning, data) run_transaction()