Пример #1
0
def get_changelog() -> str:
    """Get changelog from server."""

    logging.info("Getting changelog from server")

    changelog_request = requests.get(appinfo.API_DOMAIN +
                                     VERSION_CHANGELOG_FILE_ON_SERVER)

    if changelog_request.status_code != 200:
        logging.error("Can't get app changelog, status code - " +
                      str(changelog_request.status_code))
        raise ConnectionError("Can't get app changelog, status code - " +
                              str(changelog_request.status_code))

    return changelog_request.text
Пример #2
0
def get_latest_version_name() -> str:
    """Get name of latest version from server. (e.g. v1.0)"""

    logging.info("Getting latest version's name id from server")

    version_request = requests.get(appinfo.API_DOMAIN +
                                   VERSION_NAME_FILE_ON_SERVER)

    if version_request.status_code != 200:
        logging.error("Can't get app version name, status code - " +
                      str(version_request.status_code))
        raise ConnectionError("Can't get app version name, status code - " +
                              str(version_request.status_code))

    return version_request.text
Пример #3
0
def get_latest_version_id() -> int:
    """Get id of latest version from server."""

    logging.info("Getting latest version's id id from server")

    version_request = requests.get(appinfo.API_DOMAIN +
                                   VERSION_ID_FILE_ON_SERVER,
                                   timeout=3)

    if version_request.status_code != 200:
        logging.error("Can't get app version, status code - " +
                      str(version_request.status_code))
        raise ConnectionError("Can't get app version, status code - " +
                              str(version_request.status_code))

    return int(version_request.text)
Пример #4
0
    def run(self):
        """Begin updating."""

        logging.info("Update started")

        if is_up_to_date():
            logging.error('Already up to date')
            raise ValueError('Already up to date')

        download_new_version()

        remove_old_installation()

        extract_new_version()

        logging.info('Update finished')

        delete_update_archive()

        logging.info('Cleaned, exiting from thread')