Skip to content

Commit

Permalink
Switch to aptkit
Browse files Browse the repository at this point in the history
  • Loading branch information
clefebvre committed Sep 20, 2024
1 parent 2ca0559 commit 2492d34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 39 deletions.
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Depends: python3 (>= 3),
python3-apt,
python3-setproctitle,
aptitude,
aptkit,
gir1.2-xapp-1.0,
mint-common (>= 2),
${misc:Depends}
Expand Down
45 changes: 6 additions & 39 deletions usr/lib/linuxmint/mintbackup/mintbackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
from gi.repository import Gtk, GdkPixbuf, Gio, GLib, XApp

import apt_pkg
import aptdaemon.client
import aptdaemon.errors
from aptdaemon.enums import *
from aptdaemon.gtk3widgets import (AptConfirmDialog, AptErrorDialog,
AptProgressDialog, AptStatusIcon)
import aptkit.simpleclient

from mintcommon.installer.cache import PkgCache

Expand Down Expand Up @@ -838,38 +834,7 @@ def restore_pkg_load_from_file(self, widget=None):
self.notebook.set_current_page(TAB_PKG_RESTORE_2)
self.builder.get_object("button_forward").set_sensitive(True)

def apt_run_transaction(self, transaction):
transaction.connect("finished", self.on_transaction_finish)
dia = AptProgressDialog(transaction, parent=self.main_window)
dia.run(close_on_finished=True, show_error=True, reply_handler=lambda: True, error_handler=self.apt_on_error)

def apt_simulate_trans(self, trans):
trans.simulate(reply_handler=lambda: self.apt_confirm_deps(trans), error_handler=self.apt_on_error)

def apt_confirm_deps(self, trans):
try:
if [pkgs for pkgs in trans.dependencies if pkgs]:
dia = AptConfirmDialog(trans, parent=self.main_window)
res = dia.run()
dia.hide()
if res != Gtk.ResponseType.OK:
return
self.apt_run_transaction(trans)
except Exception as e:
print(e)

def apt_on_error(self, error):
if isinstance(error, aptdaemon.errors.NotAuthorizedError):
# Silently ignore auth failures
return
elif not isinstance(error, aptdaemon.errors.TransactionFailed):
# Catch internal errors of the client
error = aptdaemon.errors.TransactionFailed(ERROR_UNKNOWN, str(error))
dia = AptErrorDialog(error)
dia.run()
dia.hide()

def on_transaction_finish(self, transaction, exit_state):
def on_apt_install_finished(self, transaction, exit_state):
# Refresh
self.restore_pkg_load_from_file()

Expand All @@ -879,8 +844,10 @@ def restore_pkg_install_packages(self):
for row in model:
if row[0]:
packages.append(row[3])
ac = aptdaemon.client.AptClient()
ac.install_packages(packages, reply_handler=self.apt_simulate_trans, error_handler=self.apt_on_error)
client = aptkit.simpleclient.SimpleAPTClient(self.main_window)
client.set_cancelled_callback(self.on_apt_install_finished)
client.set_finished_callback(self.on_apt_install_finished)
client.install_packages(packages)

def set_selection(self, w, treeview, selection, check):
# Select / deselect all
Expand Down

0 comments on commit 2492d34

Please sign in to comment.