On Sun, 15 Sep 2013 10:19:50 +0200
Jan Friberg <[email protected]> wrote:
> Hello
> Can I in any way find out how many of our Locos member has the status
> Ubuntu Member, and who they are.
>
> And also, how to find out who in the team has or has not signed CoC?
>
> /Jan
There are two different scripts for this that require python-launchpadlib to be
installed.
Both of these code examples are written with Ubuntu Ohio in mind. To adapt
them for your community, swap in your group's name on Launchpad for instances
of "ubuntu-us-ohio" below. Both scripts output Launchpad usernames, mind you.
Neither script is quick so you may want to dump the output via a pipe to
pastebinit and come back later to see what the result is.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
To check Code of Conduct status:
#!/usr/bin/python
# -*- Encoding: UTF-8 -*-
import os
import urllib2
import json
from launchpadlib.launchpad import Launchpad
cachedir = os.path.expanduser('~/.launchpadlib/cache')
lp = Launchpad.login_anonymously('skellat.loco-user-coc', 'production',
cachedir)
loco = lp.people['ubuntu-us-ohio']
signed = 'SIGNED '
not_signed = 'NOT SIGNED'
for member_resource in loco.members:
req = urllib2.urlopen(str(member_resource))
member = json.loads(req.read())
print '%s %s (%s)' % (signed if member['is_ubuntu_coc_signer'] else
not_signed,
member['display_name'], member['web_link'])
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
To determine who are members of both the Ubuntu Members group on Launchpad and
members of your community:
#!/usr/bin/python
# -*- Encoding: UTF-8 -*-
from launchpadlib.launchpad import Launchpad
_get_team_members_done = [] # Cache of already fetched Launchpad teams
def get_coc(team, user):
team = launchpad.people[team]
members = team.members_details
for member in members:
if member.member.name == user:
return is_ubuntu_coc_signer
return None
def get_team_members(lp, team):
'''Get all members of a team and all sub-teams.
Returns a set of Person names
'''
if team in _get_team_members_done: # Don't fetch team members multiple times
return set()
_get_team_members_done.append(team)
team = lp.people[team]
members = set()
for member in team.members:
if not member.is_team:
members.add(member.name)
else: # Recurs into sub-teams
members.update(get_team_members(lp, member.name))
return members
lp = Launchpad.login_anonymously('Membership COIN CHECK',
service_root='production', version='1.0')
cloaks = get_team_members(lp, u'ubuntu-us-ohio')
_get_team_members_done = [] # Clear the cache of retrieved teams
members = get_team_members(lp, u'ubuntumembers')
# The members printed are those who are no longer members of ~ubuntumembers
print u'\n'.join(_ for _ in cloaks if _ in members)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Special thanks go to Marco Ceppi and Unit193 for making those scripts available.
Stephen Michael Kellat, MSLS
Point of Contact/Leader, Ubuntu Ohio
--
loco-contacts mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/loco-contacts