The launchpad API docs are OMG terrible, and it took me way too long to work out how to do this, so I thought I’d document it for later. Here’s how you list all the open bugs in a launchpad project using the API:
#!/usr/bin/python
import argparse
import os
from launchpadlib import launchpad
LP_INSTANCE = 'production'
CACHE_DIR = os.path.expanduser('~/.launchpadlib/cache/')
def main(username, project):
lp = launchpad.Launchpad.login_with(username, LP_INSTANCE, CACHE_DIR)
for bug in lp.projects[project].searchTasks(status=["New",
"Incomplete",
"Confirmed",
"Triaged",
"In Progress"]):
print bug
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Fetch bugs from launchpad')
parser.add_argument('--username')
parser.add_argument('--project')
args = parser.parse_args()
main(args.username, args.project)