diff -r b7f23f86cb2c -r 7dbc04a61376 pullreq_to_mantisbt.py --- a/pullreq_to_mantisbt.py Sun Jun 08 23:26:40 2014 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -#!/usr/bin/env python - -import json -import urllib -import urllib2 -import sys -import re -from suds.xsd.doctor import Import -from suds.xsd.doctor import ImportDoctor -from suds.client import Client - -bturl=sys.argv[1] -btuser=sys.argv[2] -btpass=sys.argv[3] -ticket=sys.argv[4] -bitbucketjson=sys.argv[5] -titlefile=sys.argv[6] - -with open (bitbucketjson, 'r') as fp: - jsondata = json.loads (fp.read()) - -with open (titlefile, 'r') as fp: - title = fp.read() - -regex = re.compile (r'^https://api\.bitbucket\.org/2\.0/repositories/([^/]+)/([^/]+)/pullrequests/([0-9]+)$') -match = regex.match (jsondata["links"]["self"]["href"]) - -if not match: - print "Bad JSON input (couldn't regex the pull request URL)" - quit() - -suds_import = Import ('http://schemas.xmlsoap.org/soap/encoding/', \ - 'http://schemas.xmlsoap.org/soap/encoding/') -suds_client = Client ('https://%s/api/soap/mantisconnect.php?wsdl' % bturl, \ - plugins=[ImportDoctor (suds_import)]) - -data={} -data["status"]={} -data["status"]["id"] = 60 -suds_client.service.mc_issue_update (btuser, btpass, ticket, data) -note = {} -note["text"] = "https://bitbucket.org/%s/%s/pull-request/%s" % (match.group(1), match.group(2), match.group(3)) -noteid = suds_client.service.mc_issue_note_add (btuser, btpass, ticket, note) -print "Pull request notice posted to mantisbt: https://%s/view.php?id=%s#c%s" % (bturl, ticket, noteid)