#!/usr/bin/env python
#
# From Brandon Cox
#
# Note: You MUST manually update "BATON_HOST" and associated values for your site.
#
# usage:    >  ./getBatonReport.py 'baton task ID'
# example:  >  ./getBatonReport.py 000001399c7a96ea306beed8000a007b0019006e
#

import xmlrpclib

BATON_USER = "admin"
BATON_PASS = "admin"
BATON_HOST = "10.123.25.110"
BATON_PORT = "8080"

BATON_URL = "http://%s:%s@%s:%s/Baton" % (BATON_USER, BATON_PASS, BATON_HOST, BATON_PORT)

def getReport(taskId):
	s = xmlrpclib.Server(BATON_URL)

	fileName = "/tmp/baton-report-%s.xml" % taskId
	f = file(fileName, "w")
	f.write(s.Tasks.report(taskId))
	f.close()

	print "Report was written to %s" % fileName

	

if __name__ == "__main__":
	import sys

	if len(sys.argv) > 1:
		getReport(sys.argv[1])
	else:
		getReport("0000013992a50611e8b86029000a00f0001e0010")
