Exemplo n.º 1
0
    def _check_new_version_available(self) -> Optional[_VersionResponse]:
        url = config.get(
            "apiserver.check_for_updates.url",
            "https://updates.trains.allegro.ai/updates",
        )

        uid = Settings.get_by_key("server.uuid")

        response = requests.get(
            url,
            json={
                "versions": {
                    self.component_name: str(get_version())
                },
                "uid": uid
            },
            timeout=float(
                config.get("apiserver.check_for_updates.request_timeout_sec",
                           3.0)),
        )

        if not response.ok:
            return

        response = response.json().get(self.component_name)
        if not response:
            return

        latest_version = response.get("version")
        if not latest_version:
            return

        cur_version = Version(get_version())
        latest_version = Version(latest_version)
        if cur_version >= latest_version:
            return

        return self._VersionResponse(
            version=str(latest_version),
            patch_upgrade=(latest_version.major == cur_version.major
                           and latest_version.minor == cur_version.minor),
            description=response.get("description").split("\r\n"),
        )
Exemplo n.º 2
0
def info_2_8(call: APICall):
    info(call)
    call.result.data["uid"] = Settings.get_by_key(SettingKeys.server__uuid)
Exemplo n.º 3
0
def _ensure_uuid():
    Settings.add_value(SettingKeys.server__uuid, str(uuid4()))
Exemplo n.º 4
0
def get_server_uuid() -> Optional[str]:
    return Settings.get_by_key("server.uuid")