Beispiel #1
0
    def _on_update_success(self, result):
        self._stop_updates()

        # Indicate success by filling in the progress bar.
        self._set_progress(1.0)

        # Handle the case where data was fetched and it is incorrect or lacking.
        if type(
                result
        ) is not dict or 'stable' not in result or 'unstable' not in result:
            self._set_message(
                _("The information about the latest version is broken."))
            return

        # Handle the case where the stable release is newer than our build.
        release_date, current_date = get_update_check_dates(
            result["stable"]["date"])
        stable_version = result["stable"]["version"]
        stable_signers = get_identified_release_signers(result["stable"])
        message = ""
        if stable_signers:
            if release_date > current_date:
                message = _(MSG_BODY_UPDATE_AVAILABLE).format(
                    this_version=PACKAGE_VERSION,
                    next_version=stable_version,
                    next_version_date=release_date,
                    download_uri='https://electrumsv.io/#downloads')
            # Handle the case where the we are newer than the latest stable release.
            elif StrictVersion(stable_version) < StrictVersion(
                    PACKAGE_VERSION):
                message = _(MSG_BODY_UNRELEASED_AVAILABLE).format(
                    this_version=PACKAGE_VERSION,
                    latest_version=stable_version)
            # Handle the case where we are the latest stable release.
            else:
                message = _(MSG_BODY_NO_UPDATE_AVAILABLE).format(
                    this_version=stable_version)

            # By default users ignore unstable releases.
            if not app_state.config.get('check_updates_ignore_unstable', True):
                # If we are stable.  We show later unstable releases.
                # If we are unstable.  We show later unstable releases.
                unstable_result = result["unstable"]
                unstable_signers = get_identified_release_signers(
                    result["stable"])
                release_date, current_date = get_update_check_dates(
                    unstable_result["date"])
                if unstable_signers and release_date > current_date:
                    message += _(MSG_BODY_UNSTABLE_AVAILABLE).format(
                        unstable_version=unstable_result["version"],
                        unstable_date=release_date)
        else:
            message = _(MSG_BODY_NO_SIGNEDS_AVAILABLE)

        self._set_message(message)
Beispiel #2
0
def test_get_identified_release_signers():
    entry = {
        "version":
        "1.2.0",
        "date":
        "2019-03-20T18:00:00.000000+13:00",
        "signatures": [
            "IPHe+QklAmNmIdROtaMXt8YSomu9edExbQSg+Rm8Ckc8Mm1iAvb1yYIo1eqhJvndT9b6gaVtgtjzXaNAnfyKa20=",
            "IOpCqrDwQsOjOyMfr4FiHMeY6ekyHZz/qUJ/eas0KWN/XDl9HegERwL7Qcz+jKWg66X+2k9nT3KBvV0OopNpZd8="
        ]
    }

    assert get_identified_release_signers(entry) == {
        'kyuupichan', 'rt121212121'
    }

    entry['version'] = "1.2"
    assert not get_identified_release_signers(entry)