Skip to main content

No project description provided

Project description

app-version-updater

Setting up client

Setting up client to start delay seconds after server.

ip = your_ip_str
port = your_port_int
updater_client = UpdaterClient(f"http://{ip}:{port}", "testapp", request_period=3, use_logger=True)
app_version = "0.0.1"

It is better that you provide mechanism to evaluate app_version since otherwise the following scenario possible:

  1. You update your code, compress it to .exe file, rename to next version
  2. In code occasionaly app_version was not changed
  3. Program will pull THE SAME version of itself due to version mismatch
  4. Process repeats in case you made autorestart

In case you have single-thread program you can run

updater_client.manage_app_versions(current_app_version, cred)

This will block the program and is useful if you have single-thread program. Otherwise it is better to make a thread-based approach with whatever starting condition (delay, for example):

def delayed_start(current_app_version, cred, delay: float = 0.05):
    sleep(delay)
    updater_client.manage_app_versions(current_app_version, cred)
updater_client_thread = Thread(target=delayed_start, args=(app_version, "cred", ), daemon=True)

Setting up server

Yo need to create two routes with prefix testapp (or any else you specified before):

updater_server = UpdaterServer(client_version_path=Path("./client_versions"),
                               use_logger=True, log_level=logging.DEBUG,
                               module_name="testapp-server-updater")

router = APIRouter(prefix="/testapp")

@router.get("/appVersion")
def app_version(cred: str):
    try:
        app_version = updater_server.app_version()
    except UpdaterException:
        raise HTTPException(status_code=404, detail="No client versions available")
    return app_version

@router.get("/app")
def app(version: str, cred: str):
    try:
        version = updater_server.app(version)
    except UpdaterException:
        raise HTTPException(404, f"Version \"{version}\" not found")
    return version


main_app = FastAPI()
main_app.include_router(router)

Running both client and server in one program

Replace basic_client_server with the name of your script (without extension)

if __name__ == "__main__":
    try:
        print("Starting client and server...")
        updater_client_thread.start()
        uvicorn.run(f"basic_client_server:main_app", host=ip, port=port, workers=1)
    except KeyboardInterrupt:
        updater_client_thread.join()

Expected behaviour

If the file of a newer version has just been downloaded (and located at home_dir/Downloads) the excetion would be raised:

app_version_updater.models.UpdaterException: ('Update', 'After exit the app will be updated')

If the file was downloaded previously, you'll see logs like the following:

2025-01-21 11:17:55,520 - client-updater - INFO - manage_app_versions - Requested actual client version - got 0.0.2

2025-01-21 11:17:55,520 - client-updater - INFO - manage_app_versions - Downloading version 0.0.2...

If no newer version is available:

2025-01-21 11:22:11,762 - client-updater - INFO - manage_app_versions - Requested actual client version - got 0.0.1

2025-01-21 11:22:11,763 - client-updater - INFO - manage_app_versions - Latest app version (0.0.1) matching, no update required

If folder you specified contains no existing .exe files:

2025-01-21 11:23:40,312 - client-updater - INFO - manage_app_versions - Requested actual client version - got 

2025-01-21 11:23:40,312 - client-updater - DEBUG - manage_app_versions - No client update

as well as 404 response from server.

Override versioning

In case you want something except for d.d.d.exe file versioning, you can set your own regex pattern for matching valid file versions:

updater_client = UpdaterClient(f"http://{ip}:{port}", "testapp", request_period=3, use_logger=True, validate_expression=<your expression>)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

app_version_updater-0.0.16.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

app_version_updater-0.0.16-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file app_version_updater-0.0.16.tar.gz.

File metadata

  • Download URL: app_version_updater-0.0.16.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for app_version_updater-0.0.16.tar.gz
Algorithm Hash digest
SHA256 2289bf3885a37d9ad9461659879496156ce9ff30489502c8decee5c02f76181e
MD5 0b85d5046b39dd9165f02bb522dda317
BLAKE2b-256 d7ff3be374e81718400d9305815c91dc00daf179941d2fc5ba5ea338a128116e

See more details on using hashes here.

Provenance

The following attestation bundles were made for app_version_updater-0.0.16.tar.gz:

Publisher: python-publish.yml on technomaticsDevTeam/app-version-updater

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file app_version_updater-0.0.16-py3-none-any.whl.

File metadata

File hashes

Hashes for app_version_updater-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 6963338ab423ba650d240e30a8e392d73e69bd67d5b0c7a683858a055a6f6c9f
MD5 db3d1e88d47134cf26509672d5e88df1
BLAKE2b-256 27f0a584d179c164b2c6a3d9e27b2a6f780b0a727dba465936dc7b73c5646cc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for app_version_updater-0.0.16-py3-none-any.whl:

Publisher: python-publish.yml on technomaticsDevTeam/app-version-updater

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page