poudriere-runner: add more options, use types hints and cleanup
[freebsd-maintainer-scripts/.git] / getprs.py
CommitLineData
796ddc45
SB
1#!/usr/bin/env python
2
3import bugzilla
4import os
5
6"""
7In order to use this script, complete the following instructions:
8 1. Generate API token using https://bugs.freebsd.org/bugzilla/userprefs.cgi?tab=apikey
9 2. Define environment variable FREEBSD_BZ_API_TOKEN in your shell
10"""
11
12api_key = os.environ.get("FREEBSD_BZ_API_TOKEN")
13user = os.environ.get("USER") or "sbz"
14
15bz = bugzilla.Bugzilla(
16 url="https://bugs.freebsd.org/bugzilla/xmlrpc.cgi",
17 api_key=api_key
18)
19
20query = bz.build_query(
21 product=["Ports & Packages","Base System"],
22 assigned_to=user,
23 status="__open__"
24)
25
26bugs = bz.query(query)
27for bug in sorted(bugs, key=lambda x:x.last_change_time, reverse=True):
bb017263 28 print("{:10} {:10} {:8} {:60}".format(str(bug.last_change_time), bug.id,
796ddc45
SB
29 bug.status, bug.summary))
30
31print("{} bugs currently opened.".format(len(bugs)))