Skip to content

Instantly share code, notes, and snippets.

@schwuk
Created August 10, 2010 13:40
Show Gist options
  • Save schwuk/517279 to your computer and use it in GitHub Desktop.
Save schwuk/517279 to your computer and use it in GitHub Desktop.
Simple script to slurp bugs from a Launchpad project into Pivotal Tracker stories.
#! /usr/bin/python
"""
Simple script to slurp bugs from a Launchpad project into Pivotal Tracker
stories.
Also useful as an example of using launchpadlib and pytracker.
"""
import sys
from os import path
from launchpadlib.launchpad import Launchpad
from pytracker import Story, Tracker, HostedTrackerAuth
SCRIPTNAME = path.basename(sys.argv[0])
# Set these for Launchpad:
LP_PROJECT = 'set-me'
LP_ENV = 'production' # or 'staging'
LP_LINK = 'https://bugs.launchpad.net/%s/+bug/%d'
# Set these for your Pivotal Tracker account:
PT_PROJECT = 123456
PT_USER = 'Set Me'
PT_PASS = 'Set Me'
# These filter the types of bugs we want (i.e. anything open)
STATUSES = [
'New',
'Incomplete',
'Confirmed',
'Triaged',
'In Progress',
'Fix Committed',
]
lp = Launchpad.login_with(SCRIPTNAME, LP_ENV)
project = lp.projects[LP_PROJECT]
auth = HostedTrackerAuth(PT_USER, PT_PASS)
tracker = Tracker(PT_PROJECT, auth)
tasks = project.searchTasks(status=STATUSES)
for task in tasks:
bug = task.bug
print "Processing bug #%d" % bug.id
story = Story()
story.SetStoryType('bug')
story.SetName(bug.title)
link = LP_LINK % (LP_PROJECT, bug.id)
description = '%s\n\n%s' % (bug.description, link)
story.SetDescription(description)
story.created_at = bug.date_created.timetuple()
tracker.AddNewStory(story)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment