Created
January 26, 2009 22:52
-
-
Save eston/53018 to your computer and use it in GitHub Desktop.
Get Lighthouse tickets I am responsible for in the next milestone
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
""" | |
Get Lighthouse tickets I am responsible for in the next milestone | |
Eston Bond ([email protected]) | |
""" | |
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