Created
August 24, 2012 15:29
-
-
Save anonymous/3452007 to your computer and use it in GitHub Desktop.
Get Jira Issue Available Actions using Python through Jira SOAP API
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
# -*- coding: cp936 -*- | |
# 脚本用途:通过已有的issue key,调用jira soap api getAvailableActions by issue key,获取每个issue当前available的action值,放入字典并写入文件 | |
import SOAPpy | |
import SOAPpy.Types | |
soap = SOAPpy.WSDL.Proxy('https://...?wsdl') | |
user = 'xxx' | |
password = 'xxx' | |
auth = soap.login(user, password) | |
# 将所有issue key手动作为list载入,400 < len(issueKeys) <2500,这么大的list会影响运行速度吗? | |
issueKeys = ['issueKey001', 'issueKey002',...] | |
issueDict = {} | |
# 创建函数,调用jira soap api getAvailableActions by issue key,原本是在接下来这段代码的loop中直接调用这个api,但一直出错,只有先定义个函数将值抓出来 | |
def getActions(issueKey): | |
return soap.getAvailableActions(auth, issueKey) | |
# 遍历所有issue key,将所有issue下available的action找出来并放到{issueKey:action}字典中去 | |
for issueKey in issueKeys: | |
for action in getActions(issueKey): | |
issueDict[issueKey] = action['name'] | |
f = open(r'c:/test.txt','w') | |
# 发现网络掉包严重的时候无法将所有的action获取到,因此加入了如下这个if...else...条件 | |
if len(issueDict) != len(issueKeys): | |
f.write('oops...please try it again...') | |
f.close() | |
else: | |
# 遍历字典,写入文件,issueKey availbleAction | |
for k in issueDict.keys(): | |
f.write(k) | |
f.write(' ') | |
for i in issueDict[k]: | |
f.write('%s' % i) | |
f.write('\n') | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment