Etelemetry Python Client

0.3.1 · active · verified Tue Apr 14

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

Install

Imports

Quickstart

This quickstart demonstrates how to use `etelemetry.get_project` to fetch metadata for a GitHub project and `etelemetry.check_available_version` to compare a local project's version against the etelemetry server's records, including known 'bad' versions. The project reference should be in the format 'github_org/project'.

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}.")

view raw JSON →