mass subscriptions

As you may be aware, Lubuntu is transitioning from GTK to Qt graphics libraries, which means a transition from LXDE to LXQt. Same people, more or less, just different libs. Of course, every component is different. We finally have packages in Debian and Ubuntu Xenial. There's even instructions on how to install them!

We needed to subscribe our Lubuntu Packages Team to all of these bug mails. Sure, we could have went to 18 different source package pages and just clicked our way to it, but that kind of takes a darn while.

Luckily there's a solution: launchpadlib. Just a pip install away (or use package python-launchpadlib), it gives you all sorts of control over and access to Launchpad data. It's almost better than using the web interface! Well, assuming you're fine with Python.

In our case here, it's possible to simply name a team and/or person and give it a list of packages and have it subscribe them all. Takes a few seconds after you have the code, which you can find here. The meat of the code is one line:

lp.distributions['ubuntu'].getSourcePackage(name=filearray[i]).addBugSubscription(subscriber=lp.people[teamtowrite])

which is basically like saying for a particular source package in the Ubuntu project, add a bug subscription for the particular team or person. Heck, it almost reads like normal English.

This might be useful for normal people, too. Say you wanted to subscribe to all the bugs for a particular set of packages you're helping to develop. It'd be great for that.

More than anything, it shows the power of the Launchpad API and the hard work that Colin and the rest of the Launchpad team put into it!

With that, I'd like to especially thank cjwatson, dobey, and wgrant, whom were all helpful in figuring this out on IRC, as well as tsimonq2, who was responsible for the majority of the code.

Read and Post Comments

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.

Read and Post Comments