How to determine the active Fedora Linux releases with Python?

Hi,
I want to run a script on top of branches in a package repo.

However I only want to touch branches which are not yet EOL.
That means Rawhide, the stabilization (branched but not yet released) branch, and ~two stable branches.

I’d guess there must be a rel-eng that already have such piece of code.

Sadly by myself, I’m not even able to neither find, nor determine which data I could use as the source of truth for this script.

1 Like

I can’t promise it’s pretty,[1] but here’s what I use for @issuebot:

PKGDB_COLLECTIONS_URL = "https://admin.fedoraproject.org/pkgdb/api/collections/"
USER_AGENT = "IssueBot/0.2 (+https://discussion.fedoraproject.org/u/issuebot/)"

def get_versions():

    collections_results = requests.get(
	        PKGDB_COLLECTIONS_URL, headers={'User-Agent': USER_AGENT})
	
    if collections_results.status_code != 200:
        print(
            f"Error: got {collections_results.status_code} reading Fedora versions from {PKGDB_COLLECTIONS_URL}", file=sys.stderr)
        sys.exit(7)

    collections =  collections_results.json()['collections']
	
    active = [x['version'] for x in collections if x['name']=='Fedora Linux' and x['status'] == 'Active' ]
    beta = [x['version'] for x in collections if x['name']=='Fedora Linux' and x['status'] == 'Under Development' and x['koji_name'] != 'rawhide' ]
	
    return (active,beta)
	

  1. dammit, Jim! I’m a sysadmin, not a programmer ↩︎

1 Like

The key part is https://admin.fedoraproject.org/pkgdb/api/collections/, which is authoritative.