Last active
December 21, 2015 19:39
-
-
Save andrewsomething/6356278 to your computer and use it in GitHub Desktop.
Check Planet config.ini against Launchpad team membership
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/python | |
import os | |
import ConfigParser | |
cachedir = os.path.expanduser("~/.launchpadlib/cache") | |
from launchpadlib.launchpad import Launchpad | |
launchpad = Launchpad.login_anonymously('planet check', 'production', cachedir) | |
Config = ConfigParser.ConfigParser() | |
Config.read("./config.ini") | |
team = 'ubuntumembers' | |
not_mem = 0 | |
no_nick = 0 | |
nick_not_lp = 0 | |
for section in Config.sections(): | |
warnings = [] | |
feed = section | |
name = Config.get(section, 'name') | |
try: | |
nick = Config.get(section, 'nick') | |
try: | |
member = launchpad.people[nick.lower()] | |
if any(t.name == team for t in member.super_teams): | |
pass | |
else: | |
warnings += ["Warning: %s is not in ~ubuntumembers Launchpad team." % name] | |
not_mem += 1 | |
except KeyError: | |
warnings += ["Warning: %s's nick doesn't match a Launchpad user." % name] | |
nick_not_lp += 1 | |
except Exception as exception: | |
warnings += ["Warning: Unexpected problem checking %s. \n %s" % (name, exception)] | |
except ConfigParser.NoOptionError: | |
warnings += ["Warning: %s has no Lauchpad nick listed." % name] | |
no_nick += 1 | |
if not warnings: | |
pass | |
else: | |
print "Name: " + name + '\nFeed: ' + feed | |
for warning in warnings: | |
print warning | |
print "-----------" | |
print "#### Summary ####" | |
print str(no_nick) + " entries have no nick in the config file." | |
print str(nick_not_lp) + " entries do not match a Launchpad account." | |
print str(not_mem) + " entries are not members of the %s team." % team |
Also a CSV output version that can be copied and pasted into a csv with the following columns:
Name, LaunchpadID/Nick, Blog Url, Warning
Lines 44-47
else:
for warning in warnings:
warn = warning
print name + ',' + 'https://launchpad.net~' + nick + ',' + feed + ',' + warn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I used this I modified line 44 to include the Nick and launchpad url:
print "Name: " + name + '\nFeed: ' + feed + '\nNick: ' + 'https://launchpad.net/~' + nick