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:
- You update your code, compress it to .exe file, rename to next version
- In code occasionaly app_version was not changed
- Program will pull THE SAME version of itself due to version mismatch
- 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):
ip = get_ip()
port = 49784
print(f"Testing client-server architecture for auto updater on {ip}:{port}")
updater_client = UpdaterClient(f"http://{ip}:{port}", "testapp", request_period=1, use_logger=True)
app_version = "0.0.1"
if __name__ == "__main__":
print("Starting client...")
try:
# this will decide if need to download a new version and download it
updater_client.manage_app_versions(app_version, "some_string_e.g._password_login_hash")
except UpdaterException as e: # a way to get the downloaded file path
downloaded_file_path: str = e.args[0]
os.startfile(downloaded_file_path)
sleep(5)
Setting up server
Yo need to create two routes with prefix testapp (or any else you specified before):
# setting up server
updater = UpdaterServer(client_version_path=Path("./client_versions"), # folder where to search for files
use_logger=True, log_level=logging.DEBUG,
module_name="testapp-server-updater")
# Setting up router
router = APIRouter(prefix="/testapp")
@router.get("/appVersion")
def app_version(cred: str):
try:
app_version = updater.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:
content = updater.app(version)
file_like = BytesIO(content)
file_like.seek(0)
return Response(content=content, media_type='application/octet-stream')
except UpdaterException:
raise HTTPException(404, f"Version \"{version}\" not found")
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 execution would be raised:
app_version_updater.models.UpdaterException: (<str(Path(downloaded_file))>)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file app_version_updater-0.2.3.tar.gz.
File metadata
- Download URL: app_version_updater-0.2.3.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2f2ce42941b5d62b0c16d83827453b910268cf3effa709e589385c7b8d970b6
|
|
| MD5 |
66612063ed231073451bd54e791b5996
|
|
| BLAKE2b-256 |
2d04ad37003fc0b623e5c6e3008283c2da165da2d330151e5edd894857f6cc2c
|
Provenance
The following attestation bundles were made for app_version_updater-0.2.3.tar.gz:
Publisher:
python-publish.yml on technomaticsDevTeam/app-version-updater
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
app_version_updater-0.2.3.tar.gz -
Subject digest:
f2f2ce42941b5d62b0c16d83827453b910268cf3effa709e589385c7b8d970b6 - Sigstore transparency entry: 227413069
- Sigstore integration time:
-
Permalink:
technomaticsDevTeam/app-version-updater@455c90416bdaa59fbe07ebd714925b2b8f578584 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/technomaticsDevTeam
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@455c90416bdaa59fbe07ebd714925b2b8f578584 -
Trigger Event:
push
-
Statement type:
File details
Details for the file app_version_updater-0.2.3-py3-none-any.whl.
File metadata
- Download URL: app_version_updater-0.2.3-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd1ae016ea18f603eeb7d8ddaaf4ef1497cab84bd18323143daa81d1fb77c2bc
|
|
| MD5 |
45a88cbd2e35e68cf8ac14636a1947ac
|
|
| BLAKE2b-256 |
8e0cb7017975eea634cd894de067cb1ef7b39dd21c8e1857daef690e02abf6f6
|
Provenance
The following attestation bundles were made for app_version_updater-0.2.3-py3-none-any.whl:
Publisher:
python-publish.yml on technomaticsDevTeam/app-version-updater
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
app_version_updater-0.2.3-py3-none-any.whl -
Subject digest:
cd1ae016ea18f603eeb7d8ddaaf4ef1497cab84bd18323143daa81d1fb77c2bc - Sigstore transparency entry: 227413076
- Sigstore integration time:
-
Permalink:
technomaticsDevTeam/app-version-updater@455c90416bdaa59fbe07ebd714925b2b8f578584 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/technomaticsDevTeam
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@455c90416bdaa59fbe07ebd714925b2b8f578584 -
Trigger Event:
push
-
Statement type: