Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

rupdater

Codacy Badge

rupdater is a super lightweight and dependency-free updater, that provide remote version parsing, downloading and getting hash sum of an update.

Installation

rupdater can be install from PyPi by running:

pip install rupdater

Usage

First of all, create new instance of Updater. It takes 2 arguments: current local version and URL of the remote version data file:

from rupdater import Updater
updater = Updater('1.0.0a0', 'https://example.com/remote_version.json', use_json=True)

Now you can check for an update by calling the check() method:

if updater.check():
    print('Update found!')

After checking, you may want to download the update. This can be done with download() method, that returns a file-like object (byte-mode) of the downloaded update (it stores in a temp file). You should use it only with context manager.

with updater.download() as update_file, open('update.zip', 'w+b') as f:
    f.write(update_file.read())

This example will read the data from update_file and write it to the update.zip.

More complicated example with chunk-by-chunk reading/writing:

with updater.download() as update_file, open('update.zip', 'w+b') as f:
    for chunk in iter(lambda: update_file.read(1024 * 16), b''):
        f.write(chunk)

rupdater also has hash static method, that takes 2 required arguments and 1 optional: file-like object, hashing algorithm (as string) and chunk size, which is 1024 * 16 by default. This is the example of usage:

with updater.download() as update_file:
    hashes_match = Updater.hash_file(update_file, updater.hash_algo) == updater.hash

Warning! If you want to reuse the update file, you have to seek(0). Example:

with updater.download() as update_file, open('update.zip', 'w+b') as f:
    for chunk in iter(lambda: update_file.read(1024 * 16), b''):
        f.write(chunk)
    f.seek(0)
    assert Updater.hash_file(f, updater.hash_algo) == updater.hash

You can also parse version data again manually by calling get_version_data().

Portability

rupdater.py is absolutely independent of anything at the moment. Python Standard Library is the only requirement. So if you need, you can just copy this file and use it like a single module.

Exceptions handling

rupdater does not catch any errors, you have to do it yourself as prefer. In addition, rupdater may raise ValueError when incorrect input data was given (version data file does not formatted properly, unknown hashing algorithm etc).

Metadata

Release files for rupdater 1.1.1a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rupdater 1.1.1a2
File Size Uploaded Provenance Actions
rupdater-1.1.1a2.tar.gz 4.2 kB Without provenance Details for rupdater-1.1.1a2.tar.gz

Release files / rupdater-1.1.1a2.tar.gz

Download URL rupdater-1.1.1a2.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a351faa30d8e76939db0197e8188d4bc96bbf5e09c7e2c9b920dc8f779544c2e
BLAKE2b-256 checksum
How to use checksums
2af861423912ad980f052ea5602369a563b6e0a41d68d33f342b5e363bb148d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

Security for rupdater 1.1.1a2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page