Skip to main content

Auto-updater for programs

Project description

zm-au

zm-au is a developer tool that provides an auto-updating API for programs. Note that this can be a bad idea for many reasons, so you should probably ask the user first.

Sorry for prefixing the name with "zm", but I'm sure I'll have to do that again as I have no creative names for anything anymore.

Usage

zm-au comes with two useful auto-updaters, PipAU and PipGitHubAU, and a class to base an auto-updater off of.

Let's say you are creating a Python package called skippitybop and you want it to notify the user when there is an update available on PyPI for it. Simply insert this code where you want the update check to happen.

from zm_au import PipAU

updater = PipAU("skippitybop")
updater.update(prompt=True)

When the code is run, if there is an update available on PyPI, the user will be prompted to install it via pip. If the user chooses to install it, the program will exit on success. Or failure, for that matter.

Take a guess what prompt=False would do.

Let's say you are creating a Python package called boppityskip on bigboi's GitHub repo and you want it to notify the user when there is an update available on GitHub releases for it, probably because the package is private and not on PyPI. Insert this code where you want the update check to happen.

from zm_au import PipGitHubAU

updater = PipGitHubAU("boppityskip", "bigboi/boppityskip", check_prerelease=True, dist="whl")
updater.update(prompt=True)

When the code is run, if there is an update available on GitHub releases (including prereleases) that is a whl file, the user will be prompted to install it via pip. Again, if the user chooses to install it, the program will exit on success or failure.

You can build your own AUs by making a class that inherits from BaseAU. Override the following functions as such.

  • _get_current_version - Must return the current version of the package
  • _get_latest_version - Must return the latest version of the package
  • _download - Must download the package and return the filename of the downloaded file
  • _update - Must install a package whose location is passed via the only parameter of this function

Be smart about how you use this!

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

zm_au-2.0.0.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

zm_au-2.0.0-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

Supported by

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