Last active
February 21, 2020 13:11
-
-
Save davesteele/127da7af3e48ef3d72042e45187110a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Report the pejacevic piuparts waiting count, by day, in csv format. | |
Counts are broken out by section precedence. | |
""" | |
from collections import defaultdict | |
import csv | |
import configparser | |
import io | |
import requests | |
config = configparser.ConfigParser() | |
conftext = requests.get( | |
"https://salsa.debian.org/debian/piuparts/raw/develop/instances/piuparts.conf-template.pejacevic" | |
) | |
config.read_string(conftext.text) | |
history = defaultdict(int) | |
detail = defaultdict(lambda: defaultdict(int)) | |
for section in config: | |
if any([x in section for x in ["global", "DEFAULT", "tarball/"]]): | |
continue | |
precedence = int(config[section]["precedence"]) | |
precedence = min(precedence, 8) | |
reporting_as = "" | |
if "json-sections" in config[section]: | |
reporting_as = config[section]["json-sections"] | |
url = "https://piuparts.debian.org/{}/counts.txt".format(section) | |
r = requests.get(url) | |
fp = io.StringIO(r.text) | |
dr = csv.DictReader(fp) | |
for row in dr: | |
try: | |
date = int(row["date"]) | |
wcnt = int(row[" waiting-to-be-tested"]) + int( | |
row[" waiting-for-dependency-to-be-tested"] | |
) | |
history[date] += wcnt | |
detail[date][precedence] += wcnt | |
except KeyError: | |
# this generally means the section is disabled. | |
pass | |
print("date,8,7,6,5,4,3,2,1") | |
for key in sorted(history): | |
if key >= 20180101: | |
keystr = str(key) | |
datefmt = "{}/{}/{}".format(keystr[4:6], keystr[6:8], keystr[0:4]) | |
datastr = ", ".join([str(detail[key][x]) for x in range(8, 0, -1)]) | |
print("{}, {}".format(datefmt, datastr)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment