def show_update_warning()

in files/sdw-notify.py [0:0]


def show_update_warning():
    """
    Show a graphical warning reminding the user to check for security updates
    using the Preflight Updater.

    If the user opts to check for updates, launch the Preflight Updater.
    If the user opts to defer, they will be reminded again the next time the
    notify script runs.
    """

    app = QApplication([])
    dialog = NotifyApp.NotifyDialog(Util.is_sdapp_halted())
    result = dialog.run()

    # Check results of Notify Dialog and launch the Preflight Updater if user
    # has opted to check for updates.
    if result == NotifyApp.NotifyStatus.CHECK_UPDATES:
        log.info("Launching Preflight Updater")
        updater = UpdaterApp.UpdaterApp()
        updater.show()
        sys.exit(app.exec_())
    elif result == NotifyApp.NotifyStatus.DEFER_UPDATES:
        # Currently, `DEFER_UPDATES` is a no-op, because the deferral period is
        # simply the period before the next run of the notify script (defined in
        # `securedrop-workstation/securedrop_salt/sd-dom0-crontab.sls`).
        log.info(
            "User has deferred update check. sdw-notify will run "
            "again at the next scheduled interval."
        )
        sys.exit(0)
    else:
        # NotifyApp.NotifyStatus.ERROR_UNKNOWN, meaning the dialog returned an
        # unexpected state. The error is logged in NotifyDialog.run().
        log.info(
            "Unexpected result from NotifyDialog. sdw-notify will run "
            "again at the next scheduled interval."
        )
        sys.exit(result)