where Mailman and Launchpad memberships meet

Around the time of OSCON this year, it came to my attention (thanks belkinsa!) that Ubuntu Oregon was in need of leadership. They were one of many Local Communities (or to adapt the more common parlance, LoCo) around the world seeking to spread the word of Ubuntu on a local scale. I didn't even know they existed in Oregon or otherwise, so I naturally jumped at the opportunity.

There were some challenges, many of which I discussed at our Ubuntu Online Summit (UOS) session, but I feel like we've got some good momentum going at this point. I think that being the only LoCo worldwide to have a UOS session helped quite a bit.

Much thanks is due to the LoCo Council who have been very friendly and encouraging. They even recently accepted our re-verification which, like Ubuntu Membership, is a recognition of sustained contribution.

After going through the process, it became apparent to me that metrics are good to have. Launchpad provided easy tools to figure out membership numbers and a script existed to use its API to cross reference group membership with Ubuntu Membership. Additionally, Launchpad mailing lists allowed one to easiliy figure out how many of its members were on the list.

However, using Launchpad lists is pretty darn deprecated. Instead, Ubuntu hosts its own series of lists, all using the ever-popular GNU Mailman. A much more full-featured set of tools exists for handling your mailing list this way, so it's a good thing. Additionally, it allows non-members to subscribe, which is not a bad thing.

So this leaves us with one problem: how do you equate Mailman membership to Launchpad membership? Well, your answer can be found in the mailgroupxref repo I created in the ubuntu-locoteams project (which is technically a pseudo-project, but it seemed the most fitting place). It uses a script by Mark Sapiro (included in the repo for your convenience) that can get Mailman subscriber lists and the rest of the code builds upon the aforementioned membership cross referencing script.

It turns out the Launchpad API (in the package python-launchpadlib) is very useful and easy to use. The meat of the code is pretty simple:

from launchpadlib.launchpad import Launchpad

teamemails = []

# login
lp = Launchpad.login_with('testing', 'staging')

# get the people objects of the team
team = lp.people['ubuntu-us-or']

# iterate through people objects
for member in team.members:
if member.hide_email_addresses is False:
teamemails.append(member.preferred_email_address)

# this function just calls mailman-subscribers.py, so nothing exciting
listemails = get_list_emails(hostname, listname)

for email in teamemails:
if email in listemails:
print email

Some things to note:

  • Technically there is no preferred_email_address attribute. It's actually preferred_email_address_link but that needs to be converted from Unicode and parsed. I wanted to avoid these technicalities to show how easy it is to get information from Launchpad.
  • You can login with anything instead of 'testing', but you will get a request for your personal credentials.
  • 'staging' may be down during periodic maintainence, but you can use 'qastaging' if need be.
  • If you get SSL errors, you might look to see if you installed httplib2 from outside the repos.
  • I'm not a Python wizard. Feel free to offer constructive advice, but don't lambast me for not being 'pythonic.' Someday I'll reach enlightenment.

So what is the end result of this? I found that the feature that allows Launchpad users to hide their email address is a bigger problem than I thought. Even my own email address is hidden I discovered! ☺

I think in the future I may have to look at using the name attribute and searching for it within email addresses. If you guys have any suggestions, patches are welcome. Meanwhile, I hope this is useful for your LoCo and/or Launchpad group.

blog comments powered by Disqus