Skip to content

Commit

Permalink
fix: fix program exiting telling user checks have failed when running…
Browse files Browse the repository at this point in the history
… from notification
  • Loading branch information
gerblesh committed Jul 15, 2023
1 parent cb309ac commit 7b24b8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/ublue_update/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import tomllib
import argparse
import signal

from ublue_update.notification_manager import NotificationManager
from ublue_update.update_checks.system import system_update_check
Expand Down Expand Up @@ -76,14 +77,16 @@ def check_battery_status() -> dict:
def hardware_inhibitor_checks_failed(
hardware_checks_failed: bool, failures: list, dbus_ask_for_updates: bool
):
# log the failed update
# ask if an update can be performed through dbus notifications
if check_for_updates(hardware_checks_failed) and dbus_ask_for_updates:
log.info("Harware checks failed, but update is available")
ask_for_updates()
# notify systemd that the checks have failed,
# systemd will try to rerun the unit
exception_log = "\n - ".join(failures)
raise Exception(f"update failed to pass checks: \n - {exception_log}")

else:
# notify systemd that the checks have failed,
# systemd will try to rerun the unit
exception_log = "\n - ".join(failures)
raise Exception(f"update failed to pass checks: \n - {exception_log}")
sys.exit()

def check_hardware_inhibitors() -> bool:

Expand Down Expand Up @@ -163,8 +166,6 @@ def run_updates():
"System update complete, reboot for changes to take effect",
).show(5)
log.info("System update complete")
sys.exit()


config, fallback_config = load_config()

Expand Down Expand Up @@ -233,3 +234,4 @@ def main():
).show(5)

run_updates()

4 changes: 2 additions & 2 deletions src/ublue_update/notification_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def __init__(self, app_name: str):
self.dbus_loop = DBusGMainLoop()
self.loop = GLib.MainLoop()
self._bus = dbus.SessionBus(mainloop=self.dbus_loop)
self._bus.add_signal_receiver(self._on_action, "ActionInvoked")
self._bus.add_signal_receiver(self._on_closed, "NotificationClosed")
self._bus.add_signal_receiver(self._on_action, "ActionInvoked", item)
self._bus.add_signal_receiver(self._on_closed, "NotificationClosed", item)
self._app_name = app_name
self.notifications = {}
self.notify_interface = dbus.Interface(self._bus.get_object(item, path), item)
Expand Down

0 comments on commit 7b24b8c

Please sign in to comment.