mirror of
https://github.com/dw-0/kiauh.git
synced 2026-05-05 00:38:15 +05:00
fix(core): refresh system package list in update menu after update
This commit is contained in:
@@ -251,6 +251,9 @@ class UpdateMenu(BaseMenu):
|
|||||||
self._set_status_data("klipperscreen", get_klipperscreen_status)
|
self._set_status_data("klipperscreen", get_klipperscreen_status)
|
||||||
self._set_status_data("crowsnest", get_crowsnest_status)
|
self._set_status_data("crowsnest", get_crowsnest_status)
|
||||||
|
|
||||||
|
self._fetch_system_package_update_status()
|
||||||
|
|
||||||
|
def _fetch_system_package_update_status(self) -> None:
|
||||||
update_system_package_lists(silent=True)
|
update_system_package_lists(silent=True)
|
||||||
self.packages = get_upgradable_packages()
|
self.packages = get_upgradable_packages()
|
||||||
self.package_count = len(self.packages)
|
self.package_count = len(self.packages)
|
||||||
@@ -340,15 +343,20 @@ class UpdateMenu(BaseMenu):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
pkgs: str = ", ".join(self.packages)
|
pkgs: str = ", ".join(self.packages)
|
||||||
|
|
||||||
Logger.print_dialog(
|
Logger.print_dialog(
|
||||||
DialogType.CUSTOM,
|
DialogType.CUSTOM,
|
||||||
["The following packages will be upgraded:", "\n\n", pkgs],
|
["The following packages will be upgraded:", "\n\n", pkgs],
|
||||||
custom_title="UPGRADABLE SYSTEM UPDATES",
|
custom_title="UPGRADABLE SYSTEM UPDATES",
|
||||||
)
|
)
|
||||||
if not get_confirm("Continue?"):
|
|
||||||
|
if not get_confirm("Upgrade packages?"):
|
||||||
return
|
return
|
||||||
|
|
||||||
Logger.print_status("Upgrading system packages ...")
|
Logger.print_status("Upgrading system packages ...")
|
||||||
|
|
||||||
upgrade_system_packages(self.packages)
|
upgrade_system_packages(self.packages)
|
||||||
|
self._fetch_system_package_update_status()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Logger.print_error(f"Error upgrading system packages:\n{e}")
|
Logger.print_error(f"Error upgrading system packages:\n{e}")
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -284,12 +284,14 @@ def get_upgradable_packages() -> List[str]:
|
|||||||
try:
|
try:
|
||||||
command = ["apt", "list", "--upgradable"]
|
command = ["apt", "list", "--upgradable"]
|
||||||
output: str = check_output(command, stderr=DEVNULL, text=True, encoding="utf-8")
|
output: str = check_output(command, stderr=DEVNULL, text=True, encoding="utf-8")
|
||||||
pkglist = []
|
pkglist: List[str] = []
|
||||||
|
|
||||||
for line in output.split("\n"):
|
for line in output.split("\n"):
|
||||||
if "/" not in line:
|
if "/" not in line:
|
||||||
continue
|
continue
|
||||||
pkg = line.split("/")[0]
|
pkg = line.split("/")[0]
|
||||||
pkglist.append(pkg)
|
pkglist.append(pkg)
|
||||||
|
|
||||||
return pkglist
|
return pkglist
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
raise Exception(f"Error reading upgradable packages: {e}")
|
raise Exception(f"Error reading upgradable packages: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user