Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@eston
Created January 26, 2009 22:52
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 eston/53018 to your computer and use it in GitHub Desktop.
Save eston/53018 to your computer and use it in GitHub Desktop.
Get Lighthouse tickets I am responsible for in the next milestone
"""
Get Lighthouse tickets I am responsible for in the next milestone
Eston Bond (eston@socialuxe.com)
"""
import urllib2
from xml.dom import minidom
lighthouse_token = '' # your token. can be read-only
project_root_url = '' # e.g. project.lighthouseapp.com
todo_path = '' # full path to TODO file
def get_lighthouse_data(url, token):
req = urllib2.Request(url)
req.add_header('X-LighthouseToken', token)
r = urllib2.urlopen(req)
parsed_data = minidom.parse(r)
return parsed_data
projects = {}
# get project ids
project_data = get_lighthouse_data(project_root_url + 'projects.xml', lighthouse_token)
for project in project_data.getElementsByTagName('project'):
project_id = None
project_name = None
for node in project.childNodes:
if node.nodeName == 'id':
project_id = (node.childNodes[0].nodeValue)
if node.nodeName == 'name':
project_name = (node.childNodes[0].nodeValue)
if project_id and project_name:
projects[project_id] = project_name
# get tickets
todo_file = open(todo_path, 'w')
for project_id, project_name in projects.iteritems():
underscore = ''
while len(underscore) < len(project_name):
underscore += '-'
underscore += "\n"
todo_file.write(project_name + "\n" + underscore)
# get ticket data
project_url = project_root_url + 'projects/' + str(project_id) + '/tickets.xml?q=responsible:me%20milestone:next'
ticket_data = get_lighthouse_data(project_url, lighthouse_token)
if len(ticket_data.getElementsByTagName('ticket')):
for ticket in ticket_data.getElementsByTagName('ticket'):
for node in ticket.childNodes:
if node.nodeName == 'title':
todo_file.write(node.childNodes[0].nodeValue + "\n\n")
if node.nodeName == 'number':
url = project_root_url + 'projects/' + project_id + '/tickets/' + node.childNodes[0].nodeValue
todo_file.write(url + "\n")
else:
todo_file.write("No assigned tickets for this milestone.\n\n")
todo_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment