Skip to content

Instantly share code, notes, and snippets.

@emonty
Created August 12, 2014 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emonty/4ca365d4bcd284ab9274 to your computer and use it in GitHub Desktop.
Save emonty/4ca365d4bcd284ab9274 to your computer and use it in GitHub Desktop.
import sys
from launchpadlib.launchpad import Launchpad
from launchpadlib.uris import LPNET_SERVICE_ROOT
CLOSED_STATUSES = ['Fix Released', 'Invalid', 'Fix Committed', 'Won\'t Fix']
def map_priority(importance):
if importance in ('Unknown', 'Undecided', 'Medium'):
return 'medium'
elif importance in ('Critical', 'High'):
return 'high'
return 'low'
def map_status(status):
('todo', 'inprogress', 'invalid', 'review', 'merged')
if status in ('Unknown', 'New', 'Confirmed', 'Triaged'):
return 'todo'
elif status in (
'Incomplete', 'Opinion', 'Invalid', "Won't Fix", 'Expired'):
return 'invalid'
elif status == 'In Progress':
return 'inprogress'
elif status == 'Fix Committed':
return 'review'
elif status == 'Fix Released':
return 'merged'
def process_bugs(project_name='openstack-ci'):
launchpad = Launchpad.login_anonymously('storyboard', 'production')
project_name = project_name
project = launchpad.projects[project_name]
tasks = []
for task in project.searchTasks():
messages = []
for message in task.bug.messages:
messages.append(dict(
author=message.owner.name,
content=message.content,
))
tasks.append(dict(
bug=dict(
creator=task.bug.owner.name,
title=task.bug.title,
description=task.bug.description,
is_bug=True,
),
task=dict(
creator=task.owner.name,
status=map_status(task.status),
assignee=(task.assignee and task.assignee.name),
priority=map_priority(task.importance),
),
messages=messages,
))
return tasks
def main():
return process_bugs(sys.argv[1])
if __name__ == '__main__':
tasks = process_bugs()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment