#! /usr/bin/python

import sys, json
from urllib import urlopen

url = "https://nm.debian.org/public/stats/?json"

json = json.load(urlopen(url))
if not json: sys.exit(1);
tot = 0
nm = {}

nm = { "app_new": 0,
 "app_rcvd": 0,
 "app_hold": 0,
 "adv_rcvd": 0,
 "app_ok": 0,
 "am_rcvd": 0,
 "am": 0,
 "am_hold": 0,
 "am_ok": 0,
 "fd_hold": 0,
 "fd_ok": 0,
 "dam_hold": 0,
 "dam_ok": 0,
 "done": 0,
 "cancelled": 0 }

string = "N"
for field in nm.keys():
  nm[field] = json['by_progress'].get(field, 0)
  tot = tot + nm[field]
  string = string + ":" + str(nm[field])

print string + ":" + str(tot)
