#!/usr/bin/python -tt '''Calculate number of active packager owners.''' import sys import getpass from fedora.client import AccountSystem from fedora.client import PackageDB username = sys.argv[1] password = getpass.getpass() def get_cla(fas): people = fas.people_by_groupname('cla_done') return [p['username'] for p in people] def get_packagers(fas): people = fas.people_by_groupname('packager') return [p['username'] for p in people] def get_at_redhat(fas): people = fas.people_by_id() people2= fas.people_by_groupname('cla_redhat') people3=set() for p in people2: people3.add(p['username']) for p in people.values(): if (p.email.endswith('@redhat.com') or p.bugzilla_email.endswith('@redhat.com')): people3.add(p.username) return list(people3) if __name__ == '__main__': # Stats we've decided to gather. Explained below where they are printed totalMaintainers = 0 totalPkgsWithMaint = 0 fas = AccountSystem(username=username, password=password) redhaters = {} users = {} people = get_packagers(fas) users.update(zip(people, [0] * len(people))) redhat = get_at_redhat(fas) redhaters.update(zip(redhat, [0] * len(redhat))) total_packagers= set() redhat_packagers= set() total_owners= set() # Read in information about maintainers of packages pkgdb = PackageDB(username=username, password=password) packages = pkgdb.send_request('/lists/vcs').packageAcls print packages for pkg in packages: packagers = set() for branch in ('devel',): if branch in packages[pkg]: print packages[pkg][branch] for pkger in packages[pkg][branch].commit.people: if pkger in users: packagers.add(pkger) total_packagers.add(pkger) if pkger in redhaters: redhat_packagers.add(pkger) if packagers: totalPkgsWithMaint += 1 for pkger in packagers: users[pkger] += 1 totalMaintainers = len(total_packagers) redhatMaintainers = len(redhat_packagers) pkger_distribution = {} for num_pkgs in users.values(): try: pkger_distribution[num_pkgs] += 1 except KeyError: pkger_distribution[num_pkgs] = 1 distribution = pkger_distribution.keys() distribution.sort() # Summarise our findings print 'Total Maintainers :', totalMaintainers print 'Red Hat Maintainers:', redhatMaintainers print 'Total Packages:', len(packages) print 'Total Packages with a Maintainer listed as owner/comaint:', totalPkgsWithMaint print # print 'Number of packages comaintained per user' # print '# Packages | # Maintainers' # for num_pkgs in distribution: # print ' %9d | %d' % (num_pkgs, pkger_distribution[num_pkgs])