Etelemetry Python Client
Etelemetry is a lightweight Python client API designed to communicate with the etelemetry server. It allows projects to check for available versions, identify 'bad' versions, and report usage statistics. The current version is 0.3.1. Releases appear to be ad-hoc but active, with the latest significant update in October 2023.
Warnings
- breaking Version 0.3.0 dropped support for Python 3.6. Users on Python 3.6 or older must upgrade their Python environment before upgrading to `etelemetry>=0.3.0`.
- gotcha When integrating `etelemetry` into a project's `__init__.py` for automated version checking, the snippet provided in documentation assumes the presence of `__version__` and a logger instance (e.g., `usemylogger`). Ensure these variables are defined in your module or adapt the snippet accordingly.
- gotcha The `get_project` and `check_available_version` functions expect project identifiers in the format 'github_org/project' (e.g., 'nipy/nipype'). Incorrect formatting will result in errors or no data found.
Install
-
pip install etelemetry
Imports
- etelemetry
import etelemetry
Quickstart
import etelemetry
import os
# Example 1: Get project version information
project_info = etelemetry.get_project("nipy/nipype")
print(f"Project 'nipy/nipype' info: {project_info}")
# Example 2: Check for available and bad versions
# Simulate project_version from your application
my_project_org = os.environ.get('ETELEMETRY_TEST_ORG', 'sensein')
my_project_name = os.environ.get('ETELEMETRY_TEST_PROJECT', 'etelemetry-client')
my_project_version = os.environ.get('ETELEMETRY_TEST_VERSION', '0.2.1') # Using an example old version
full_project_slug = f"{my_project_org}/{my_project_name}"
print(f"\nChecking version {my_project_version} for {full_project_slug}...")
version_status = etelemetry.check_available_version(
full_project_slug,
my_project_version
)
if version_status and 'bad_versions' in version_status and my_project_version in version_status['bad_versions']:
print(f"WARNING: You are using a known bad version ({my_project_version}) for {full_project_slug}. Please upgrade!")
elif version_status and 'version' in version_status and version_status['version'] != my_project_version:
print(f"INFO: A newer version ({version_status['version']}) of {full_project_slug} is available. You are using {my_project_version}.")
else:
print(f"INFO: You are using the latest or a good version ({my_project_version}) for {full_project_slug}.")