Skip to content

Commit

Permalink
style: cleaned up old code
Browse files Browse the repository at this point in the history
  • Loading branch information
gerblesh committed Oct 9, 2023
1 parent 3fc4580 commit eee533b
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions src/ublue_update/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,9 @@ def ask_for_updates():
if "universal-blue-update-confirm" in out.stdout.decode("utf-8"):
run_updates(cli_args)


def check_for_updates() -> bool:
"""Tracks whether any updates are available"""
update_available: bool = False
if system_update_available:
update_available = True
if update_available:
return True
log.info("No updates are available.")
return False


def hardware_inhibitor_checks_failed(
hardware_checks_failed: bool, failures: list, hardware_check: bool
):
def hardware_inhibitor_checks_failed(failures: list, hardware_check: bool):
# ask if an update can be performed through dbus notifications
if check_for_updates() and not hardware_check:
if system_update_available and not hardware_check:
log.info("Harware checks failed, but update is available")
ask_for_updates()
# notify systemd that the checks have failed,
Expand Down Expand Up @@ -209,6 +195,7 @@ def run_updates(args):
cli_args = None
system_update_available: bool = False


def main():

# setup argparse
Expand Down Expand Up @@ -245,21 +232,21 @@ def main():
if cli_args.wait:
transaction_wait()
os._exit(0)

system_update_available = system_update_check()

if not cli_args.force and not cli_args.updatecheck:
hardware_checks_failed, failures = check_hardware_inhibitors()
if hardware_checks_failed:
hardware_inhibitor_checks_failed(
hardware_checks_failed,
failures,
cli_args.check,
)
if cli_args.check:
os._exit(0)

if cli_args.updatecheck:
update_available = check_for_updates()
if not update_available:
if not system_update_available:
raise Exception("Update not available")
os._exit(0)

Expand Down

0 comments on commit eee533b

Please sign in to comment.