Sun, 08 Jun 2014 23:24:46 +0300
- axed the python interfacing part completely..
4
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | #!/usr/bin/env python |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | import json |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | import urllib |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | import urllib2 |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | import sys |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | import re |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | from suds.xsd.doctor import Import |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | from suds.xsd.doctor import ImportDoctor |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | from suds.client import Client |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | bturl=sys.argv[1] |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | btuser=sys.argv[2] |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | btpass=sys.argv[3] |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | ticket=sys.argv[4] |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | bitbucketjson=sys.argv[5] |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | titlefile=sys.argv[6] |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | with open (bitbucketjson, 'r') as fp: |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | jsondata = json.loads (fp.read()) |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | with open (titlefile, 'r') as fp: |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | title = fp.read() |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | regex = re.compile (r'^https://api\.bitbucket\.org/2\.0/repositories/([^/]+)/([^/]+)/pullrequests/([0-9]+)$') |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | match = regex.match (jsondata["links"]["self"]["href"]) |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | if not match: |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | print "Bad JSON input (couldn't regex the pull request URL)" |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | quit() |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | suds_import = Import ('http://schemas.xmlsoap.org/soap/encoding/', \ |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | 'http://schemas.xmlsoap.org/soap/encoding/') |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | suds_client = Client ('https://%s/api/soap/mantisconnect.php?wsdl' % bturl, \ |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | plugins=[ImportDoctor (suds_import)]) |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | |
5
9d63b4f82112
- axed the python interfacing part completely..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
37 | data={} |
9d63b4f82112
- axed the python interfacing part completely..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
38 | data["status"]={} |
4
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | data["status"]["id"] = 60 |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | suds_client.service.mc_issue_update (btuser, btpass, ticket, data) |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | note = {} |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | note["text"] = "https://bitbucket.org/%s/%s/pull-request/%s" % (match.group(1), match.group(2), match.group(3)) |
7c02e457e6ab
- added automatic tracker updating but commented it out since it also bumps timestamps on every note on said ticket...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | noteid = suds_client.service.mc_issue_note_add (btuser, btpass, ticket, note) |
5
9d63b4f82112
- axed the python interfacing part completely..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
44 | print "Pull request notice posted to mantisbt: https://%s/view.php?id=%s#c%s" % (bturl, ticket, noteid) |