### PyUpdater Build Command for Release Channels Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/usage-cli-advanced.md Demonstrates how to use the `pyupdater build` command with the `--app-version` flag to specify different release channels. This includes examples for Stable, Beta, and Alpha releases, showing the distinct versioning patterns for each. ```bash $ pyupdater build --app-version=3.30.1 $ pyupdater build --app-version=2.1 $ pyupdater build --app-version=1.0 ``` ```bash $ pyupdater build --app-version=1.0.1b $ pyupdater build --app-version=3.1b2 $ pyupdater build --app-version=11.3.1beta2 ``` ```bash $ pyupdater build --app-version=1.0.1a $ pyupdater build --app-version=5.0alpha $ pyupdater build --app-version=1.1.1alpha1 ``` -------------------------------- ### PyUpdater Release Channel Examples Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/usage-cli-advanced.md Demonstrates how to specify different release channels (Stable, Beta, Alpha) when building application versions using the PyUpdater CLI. ```APIDOC ## PyUpdater Release Channels PyUpdater supports three release channels: Stable, Beta, and Alpha. These channels are specified when providing a version number to the `--app-version` flag during the build process. Patches are created for each channel. ### Stable Channel Examples ```bash $ pyupdater build --app-version=3.30.1 $ pyupdater build --app-version=2.1 $ pyupdater build --app-version=1.0 ``` ### Beta Channel Examples ```bash $ pyupdater build --app-version=1.0.1b $ pyupdater build --app-version=3.1b2 $ pyupdater build --app-version=11.3.1beta2 ``` ### Alpha Channel Examples ```bash $ pyupdater build --app-version=1.0.1a $ pyupdater build --app-version=5.0alpha $ pyupdater build --app-version=1.1.1alpha1 ``` ### Method `build` (CLI command) ### Parameters #### Command Line Arguments - **`--app-version`** (string) - Required - The version number for the application, including the release channel suffix if applicable. ``` -------------------------------- ### Install PyUpdater with Optional Dependencies Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/changelog.md Commands to install PyUpdater with specific feature sets. Use the patch flag for patch support or the all flag to include AWS S3 and SCP upload plugins. ```bash pip install pyupdater[patch] pip install pyupdater[all] ``` -------------------------------- ### PyUpdater Client: Implementing a Custom File Downloader Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/usage-client-advanced.md Provides an example of creating a custom file downloader class for PyUpdater. The custom downloader must adhere to a specific signature and handle downloading and verification of files. ```python from pyupdater.client import Client, DefaultClientConfig class MyDownloader: def __init__(self, filename, urls, **kwargs): self.filename = filename self.urls = urls self.hexdigest = kwargs.get("hexdigest") self._data = None def download_verify_return(self): # Download the data from the endpoint and return return self._data def download_verify_write(self): # Write the downloaded data to the current dir try: with open(self.filename, 'wb') as f: f.write(self._data) return True except: return False client = Client(DefaultClientConfig(), downloader=MyDownloader) ``` -------------------------------- ### Manage PyUpdater Plugins Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/usage-cli.md Lists installed PyUpdater plugins and allows for their configuration. Plugins extend PyUpdater's functionality, such as enabling uploads to different services. Official plugins can be installed using pip. ```bash # You can install the official plugins with # pip install pyupdater[s3, scp] $ pyupdater plugins ``` ```bash $ pyupdater settings --plugin s3 ``` -------------------------------- ### Install PyUpdater Patch Dependency (>= 2.0.3) Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/upgrading.md This command installs the PyUpdater patch functionality, which is now included by default and deprecated as a separate installable extra. ```bash pip install pyupdater[patch] ``` -------------------------------- ### GET /update_check Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/usage-client-advanced.md Checks for available application updates from a specified release channel. ```APIDOC ## GET /update_check ### Description Checks for updates for a specific application version. Supports different release channels such as stable, beta, or alpha. ### Method GET ### Endpoint client.update_check(APP_NAME, APP_VERSION, channel=None) ### Parameters #### Query Parameters - **APP_NAME** (string) - Required - The name of the application. - **APP_VERSION** (string) - Required - The current version of the application. - **channel** (string) - Optional - The release channel (e.g., 'beta'). Defaults to 'stable'. ### Request Example client.update_check('MyApp', '1.0.0', channel='beta') ### Response #### Success Response (200) - **app_update** (object) - An update object if an update is available, otherwise None. #### Response Example { "update_available": true, "version": "1.1.0" } ``` -------------------------------- ### Initialize PyUpdater Client Source: https://context7.com/digital-sapphire/pyupdater/llms.txt Demonstrates how to instantiate the Client class with various configurations, including automatic refresh, progress hooks, custom headers for authentication, and custom data directories. ```python from pyupdater.client import Client from client_config import ClientConfig APP_NAME = 'MyApp' APP_VERSION = '1.0.0' # Initialize client with refresh on init client = Client(ClientConfig(), refresh=True) # Or initialize and refresh manually client = Client(ClientConfig()) client.refresh() # Initialize with progress hooks def print_progress(info): print(f"Downloaded: {info['downloaded']}/{info['total']} bytes") print(f"Status: {info['status']}") print(f"Percent: {info['percent_complete']}%") client = Client( ClientConfig(), refresh=True, progress_hooks=[print_progress] ) # Initialize with custom headers (e.g., basic auth) headers = {'basic_auth': 'username:password'} client = Client(ClientConfig(), headers=headers) # Initialize with custom data directory client = Client(ClientConfig(), data_dir='/custom/update/path') ``` -------------------------------- ### Implementing a Custom Uploader Plugin Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/create-upload-plugin.md This documentation outlines how to create a custom uploader class by extending BaseUploader and registering it via setuptools entry points. ```APIDOC ## Class Implementation: BaseUploader ### Description Create a custom plugin by inheriting from `pyupdater.core.uploader.BaseUploader`. Plugins must define a `name` and `author`, and implement `init_config` and `set_config` methods. ### Implementation Details - **init_config(self, config)**: Called after class initialization to load configuration settings. - **set_config(self, config)**: Used to prompt the user for configuration input or retrieve it from environment variables. - **upload_file(self, filename)**: Core method to handle the file upload logic. ### Registration Plugins are registered in `setup.py` using the `pyupdater.plugins` entry point: ```python entry_points={ 'pyupdater.plugins': [ 'my_uploader = my_uploader:MyUploader', ] } ``` ### Configuration Example ```python def set_config(self, config): server_name = self.get_answer("Please enter server name\n--> ") config["server_url"] = server_name ``` ``` -------------------------------- ### CLI Command: pyupdater init Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/commands.md Initializes a repository for use with PyUpdater. ```APIDOC ## CLI COMMAND: pyupdater init ### Description Initializes the current directory for PyUpdater. Creates configuration and data directories along with a client_config.py file. ### Method CLI ### Request Example $ pyupdater init ``` -------------------------------- ### Initialize PyUpdater Repository Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/commands.md The init command initializes a new or existing repository for use with PyUpdater. It prompts the user for application details and creates necessary configuration files and directories, including a config directory, a data directory, and a client_config.py file. These files manage PyUpdater settings and can be regenerated upon updates. ```bash pyupdater init [-h] optional arguments: -h, --help show this help message and exit ``` ```bash $ pyupdater init ``` -------------------------------- ### PyUpdater Client Initialization Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/usage-client.md Demonstrates how to initialize the PyUpdater client, either with or without immediate refresh and progress hooks. ```APIDOC ## PyUpdater Client Initialization ### Description Initialize a client with the ClientConfig & later call refresh to get latest update data. Progress hooks can also be added later. ### Method N/A (Initialization) ### Endpoint N/A (Client-side) ### Parameters N/A ### Request Example ```python from pyupdater.client import Client from client_config import ClientConfig # Initialize client and refresh later client = Client(ClientConfig()) client.refresh() # Add progress hook def print_status_info(info): total = info.get(u'total') downloaded = info.get(u'downloaded') status = info.get(u'status') print downloaded, total, status client.add_progress_hook(print_status_info) ``` ### Response N/A --- ### Description Initialize a client with the ClientConfig, add progress hook & refresh during initialization. ### Method N/A (Initialization) ### Endpoint N/A (Client-side) ### Parameters N/A ### Request Example ```python from pyupdater.client import Client from client_config import ClientConfig def print_status_info(info): total = info.get(u'total') downloaded = info.get(u'downloaded') status = info.get(u'status') print downloaded, total, status client = Client( ClientConfig(), refresh=True, progress_hooks=[print_status_info] ) ``` ### Response N/A ``` -------------------------------- ### PyUpdater Client: Setting and Adding Progress Callbacks Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/usage-client-advanced.md Illustrates how to set up progress hooks for downloads, either during client initialization or by adding them later. Progress hooks receive a dictionary with download status details. ```python # Progress hooks get passed a dict with the below keys. # total: total file size # downloaded: data received so far # status: will show either downloading or finished # percent_complete: Percentage of file downloaded so far # time: Time left to complete download def progress(data): print('Time remaining'.format(data['time'])) def log_progress(data): log.debug('Total file size %s', data['total']) # You can initialize the client with a callbacks client = Client(ClientConfig(), progress_hooks=[progress, log_progress]) # Or you can add them later. client = Client(ClientConfig()) client.add_progress_hook(log_progress) client.add_progress_hook(progress) ``` -------------------------------- ### Configure PyUpdater Plugin Entry Points Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/create-upload-plugin.md This Python code snippet demonstrates how to configure PyUpdater to discover custom plugins using setuptools entry points. It specifies that the 'my_uploader' plugin, implemented by the MyUploader class in the 'my_uploader' module, should be available under the 'pyupdater.plugins' namespace. This is typically done within a `setup.py` file. ```python setup( provides=['pyupdater.plugins',], entry_points={ 'pyupdater.plugins': [ 'my_uploader = my_uploader:MyUploader', ] }, ``` -------------------------------- ### PyUpdater Client: Checking for Updates with Release Channels Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/usage-client-advanced.md Demonstrates how to check for application updates using the PyUpdater client, specifying different release channels (stable, beta) or defaulting to stable if no channel is provided. ```python # Requesting updates from the beta channel app_update = client.update_check(APP_NAME, APP_VERSION, channel='beta') # If no channel is specified, stable will be used app_update = client.update_check(APP_NAME, APP_VERSION) ``` -------------------------------- ### Initialize PyUpdater Repository Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/usage-cli.md Initializes the PyUpdater repository in your project's root directory. This process creates necessary configuration files and directories for PyUpdater to manage updates. ```bash $ pyupdater init ``` -------------------------------- ### Check and Apply Asset Updates Source: https://context7.com/digital-sapphire/pyupdater/llms.txt Demonstrates the standard workflow for checking, downloading, and extracting application updates using the PyUpdater client. ```python lib_update = client.update_check(ASSET_NAME, ASSET_VERSION) if lib_update is not None: print(f"New version available: {lib_update.version}") lib_update.download() if lib_update.is_downloaded(): if lib_update.extract(): print(f"Asset extracted to: {lib_update.update_folder}") else: print("Extraction failed") ``` -------------------------------- ### PyUpdater Plugin Configuration Methods Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/create-upload-plugin.md This Python code illustrates two methods for handling configuration within a PyUpdater plugin: `set_config` and `init_config`. `set_config` prompts the user for input (e.g., a server name) and stores it in the configuration. `init_config` is called after initialization and retrieves configuration values (e.g., `server_url`) that were previously set. ```python # Saves the config to disk. def set_config(self, config): server_name = self.get_answer("Please enter server name\n--> ") config["server_url"] = server_name # Will be called after the class is initialized. def init_config(self, config): self.server_url = config["server_url"] ``` -------------------------------- ### Create Custom Upload Plugin Source: https://context7.com/digital-sapphire/pyupdater/llms.txt Provides a template for creating a custom uploader plugin by subclassing BaseUploader and defining setuptools entry points. ```python from pyupdater.core.uploader import BaseUploader import requests class MyCloudUploader(BaseUploader): name = 'mycloud' def upload_file(self, filename): with open(filename, 'rb') as f: response = requests.post(f"{self.endpoint}/upload", files={'file': f}) return response.status_code == 200 # setup.py entry point entry_points={'pyupdater.plugins': ['mycloud = my_uploader:MyCloudUploader']} ``` -------------------------------- ### Configure Update Strategies Source: https://context7.com/digital-sapphire/pyupdater/llms.txt Configures how PyUpdater handles binary replacement on Windows, choosing between overwriting the existing file or renaming it. ```python from pyupdater.client import Client from pyupdater.client.updates import UpdateStrategy from client_config import ClientConfig client = Client(ClientConfig(), strategy=UpdateStrategy.RENAME) client.refresh() app_update = client.update_check('MyApp', '1.0.0') if app_update: app_update.download() if app_update.is_downloaded(): app_update.extract_restart() ``` -------------------------------- ### POST /download Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/usage-client-advanced.md Initiates a file download for an available update, optionally in the background. ```APIDOC ## POST /download ### Description Downloads the update package. Can be performed in the background and supports progress tracking via hooks. ### Method POST ### Endpoint app_update.download(background=bool) ### Parameters #### Request Body - **background** (boolean) - Optional - If true, the download runs in a background thread. ### Request Example app_update.download(background=True) ### Response #### Success Response (200) - **status** (boolean) - Returns True if the download was initiated successfully. ``` -------------------------------- ### Client Initialization Source: https://context7.com/digital-sapphire/pyupdater/llms.txt Initializes the PyUpdater Client to manage update checks and configuration settings. ```APIDOC ## Client Initialization ### Description Initializes the main client class for checking and downloading updates. Requires a configuration object. ### Method Constructor ### Parameters #### Request Body - **config** (ClientConfig) - Required - Configuration object containing application settings. - **refresh** (bool) - Optional - Whether to refresh update data on initialization. - **progress_hooks** (list) - Optional - List of callback functions for download progress. - **headers** (dict) - Optional - Custom HTTP headers for requests. - **data_dir** (str) - Optional - Custom directory path for update files. ### Request Example client = Client(ClientConfig(), refresh=True, progress_hooks=[callback]) ``` -------------------------------- ### Build Application Executable with PyUpdater Source: https://github.com/digital-sapphire/pyupdater/blob/main/docs/commands.md The build command automates the process of creating a distributable application executable by wrapping PyInstaller. It archives the built executable in a PyUpdater-compatible format and places it in the pyu-data/new directory. Options allow specifying archive format, cleaning the build cache, setting the application version (including alpha/beta tags for specific release channels), and printing PyInstaller logs. ```bash pyupdater build [opts]