1 Star 0 Fork 1

wjf35/loadjiradata2excel

forked from 欧文/loadjiradata2excel 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
jira_P.py 10.51 KB
一键复制 编辑 原始数据 按行查看 历史
yuanshuai 提交于 2019-10-10 11:25 . first commit
# -*- coding: utf-8 -*-
from jira import JIRA
from KDissue import *
from MailSender import *
from ExcelDeal import KDExcel
usemail = True
MailList = ['sunxue@kaidi.com','huaxiaobin@kaidi.com','zhangweijie@kaidi.com','hesongjiang@kaidi.com','gejunning@kaidi.com','liuweijun@kaidi.com','zhouyeqing@kaidi.com','yangzhengguang@kaidi.com','zongyue@kaidi.com','liuzunpeng@kaidi.com','wangdianren@kaidi.com','wangwenli@kaidi.com','dongjianbo@kaidi.com','shaopeng@kaidi.com','liuweidong@kaidi.com','luchangming@kaidi.com','chengleilei@kaidi.com','yejunchen@kaidi.com','kanrenfeng@kaidi.com','xuzhiqi@kaidi.com','fanzhengqing@kaidi.com','huangxiaolong@kaidi.com','niewei@kaidi.com','wangyulong@kaidi.com','lixu@kaidi.com','shiyitao@kaidi.com','yaobutang@kaidi.com','gezhennan@kaidi.com','cuifang@kaidi.com','qianwenhuan@kaidi.com','xuzhiming@kaidi.com','zhouzhu@kaidi.com','lijie@kaidi.com','xiahongtao@kaidi.com','xujun@kaidi.com','yuanshuai@kaidi.com','guofayong@kaidi.com','taopengfei@kaidi.com','kongyuan@kaidi.com','lijiayun@kaidi.com','guofei@kaidi.com','lihao@kaidi.com','wangbeilei@kaidi.com','zhumeixiang@kaidi.com','zhuangwenxu@kaidi.com','wujian@kaidi.com','liujingjing@kaidi.com','maxiangxiang@kaidi.com','wujixiong@kaidi.com','liuqilin@kaidi.com','yaoxin@kaidi.com','wangziming@kaidi.com','wukai@kaidi.com','yangwenfeng@kaidi.com','sunfulai@kaidi.com','zengchongmin@kaidi.com','huanghuailong@kaidi.com']
DevelopMail = ['yaobutang@kaidi.com','zhuangwenxu@kaidi.com','gezhennan@kaidi.com','xuzhiming@kaidi.com','yuanshuai@kaidi.com','lihao@kaidi.com','wangbeilei@kaidi.com','wujian@kaidi.com','liuqilin@kaidi.com','yaoxin@kaidi.com','wangziming@kaidi.com','wukai@kaidi.com','yangwenfeng@kaidi.com','sunfulai@kaidi.com','zengchongmin@kaidi.com','huanghuailong@kaidi.com']
#登录jira
def login_jira(username,password):
jira = JIRA("http://192.168.1.21:8080",basic_auth=(username,password))
return jira
def searchIssues(jql, max_results=1000):
''' Search issues
@param jql: JQL, str
@param max_results: max results, int, default 100
@return issues: result, list
'''
try:
issues = jira.search_issues(jql, maxResults=max_results)
return issues
except Exception as e:
print(e)
def SearchbyJQL(jql):
_list = []
issues = searchIssues(jql)
for issue in issues:
# print('{0}: {1} '.format(issue.key, issue.fields.status))
_issue = JiraIssue()
_content = []
_key = str(issue.key)
_type = str(issue.fields.customfield_10700)
_create_time = str(issue.fields.created)
_version = str(issue.fields.customfield_10701 if issue.fields.customfield_10701 != None else ('' if len(issue.fields.versions) == 0 else (issue.fields.versions[0].name if len(issue.fields.versions) == 1 else issue.fields.versions[len(issue.fields.versions) - 1].name)))
_discrip = str(issue.fields.summary )
_discrip = str(_discrip + '\n' + str(issue.fields.description) if issue.fields.description != None else '')
_ctreater = str(issue.fields.creator)
_rootcause = str(issue.fields.customfield_10600)
_fix_discrip = str(issue.fields.customfield_10702)
_update_time = str(issue.fields.updated)
_fixVersion = str('' if len(issue.fields.fixVersions) == 0 else (issue.fields.fixVersions[0].name if len(issue.fields.fixVersions) == 1 else issue.fields.fixVersions[len(issue.fields.fixVersions) - 1].name))
_howtocheck = str(issue.fields.customfield_10703)
_handler = str(issue.fields.assignee)
_checkdiscrip = str(issue.fields.customfield_10704)
_status = str(issue.fields.status)
_check_time = str(_update_time if _status == u'已关闭' else None)
# print(_check_time)
_updater = str(issue.fields.reporter if _status == u'已关闭' else None)
_result = str(issue.fields.resolution)
_content.append(_key)
_content.append(_type)
_content.append(_create_time[0:10] if _create_time != None else None)
_content.append(_version)
_content.append(_discrip)
_content.append(_ctreater)
_content.append(_rootcause)
_content.append(_fix_discrip)
_content.append(_update_time[0:10] if _update_time != None else None)
_content.append(_fixVersion)
_content.append(_howtocheck)
_content.append(_checkdiscrip)
_content.append(_handler)
_content.append(_updater)
_content.append(_result)
_content.append(_check_time[0:10] if _check_time != None else None)
_content.append(_status)
_issue.insertParam(_content)
_list.append(_issue)
# print('****************************************************************')
return _list
if __name__ == '__main__':
jira = login_jira('wukai','wkwkwk1314')
allfields = jira.fields()
#nameMap = {field['name']:field['id'] for field in allfields}
#for field in allfields:
# print('{0}: {1}'.format(field['name'],field['id']))
iswin = False if "win" not in str(sys.platform) else True
excelhandle = None
if iswin:
excelhandle = KDExcel("..\\KdIssueCollect.xlsx")
else:
excelhandle = KDExcel("../KdIssueCollect.xlsx")
if usemail:
mailsender = EmailSender()
#************************TeachUI begin***************************************
# search project 01
jql = '''
project = 10003 AND component = TeachUI AND project = TSXT
'''
m_list = SearchbyJQL(jql)
# search project 02
jql = '''
project = 10100 AND component = TeachUI AND project = TSXT02
'''
m_list = m_list + SearchbyJQL(jql)
#TODO send the _list to excel deal model
excelhandle.dealData(m_list, "TeachUI")
#**************************TeachUI end*************************************
m_list = []
#************************ManageUnit(管理平台) begin***************************************
# search project 01
jql = '''
project = 10003 AND component = "ManageUnit(管理平台)" AND project = TSXT
'''
m_list = SearchbyJQL(jql)
# search project 02
jql = '''
project = 10100 AND component = "ManageUnit(管理平台)" AND project = TSXT02
'''
m_list = m_list + SearchbyJQL(jql)
#TODO send the _list to excel deal model
excelhandle.dealData(m_list, "ManageUnit")
#**************************ManageUnit(管理平台) end*************************************
m_list = []
#************************实时交互控制系统 begin***************************************
# search project 01
jql = '''
project = 10003 AND component = "实时交互控制系统" AND project = TSXT
'''
m_list = SearchbyJQL(jql)
# search project 02
jql = '''
project = 10100 AND component = "实时交互控制系统" AND project = TSXT02
'''
m_list = m_list + SearchbyJQL(jql)
#TODO send the _list to excel deal model
excelhandle.dealData(m_list, "BoardCtrl")
#**************************实时交互控制系统 end*************************************
m_list = []
#************************Kinematics(运动学) begin***************************************
# search project 01
jql = '''
project = 10003 AND component = "Kinematics(运动学)" AND project = TSXT
'''
m_list = SearchbyJQL(jql)
# search project 02
jql = '''
project = 10100 AND component = "Kinematics(运动学)" AND project = TSXT02
'''
m_list = m_list + SearchbyJQL(jql)
#TODO send the _list to excel deal model
excelhandle.dealData(m_list, "Kinematics")
#**************************Kinematics(运动学) end*************************************
m_list = []
#************************Servo(伺服) begin***************************************
# search project 02
jql = '''
project = 10100 AND component = "Servo(伺服)" AND project = TSXT02
'''
m_list = SearchbyJQL(jql)
#TODO send the _list to excel deal model
excelhandle.dealData(m_list, "Servo")
#**************************Servo(伺服) end*************************************
m_list = []
#************************Electron(电子) begin***************************************
# search project 02
jql = '''
project = 10100 AND component = "Electron(电子)" AND project = TSXT02
'''
m_list = SearchbyJQL(jql)
#TODO send the _list to excel deal model
excelhandle.dealData(m_list, "Electron")
#**************************Electron(电子) end*************************************
m_list = []
#************************Machine(机械) begin***************************************
# search project 02
jql = '''
project = 10100 AND component = "Machine(机械)" AND project = TSXT02
'''
m_list = SearchbyJQL(jql)
#TODO send the _list to excel deal model
excelhandle.dealData(m_list, "Machine")
#**************************Machine(机械) end*************************************
developList = excelhandle.developIssueList
excelhandle.close()
if usemail:
if iswin:
mailsender.SendMail(MailList, str(u'凯迪智能装备事业部开发问题汇总-' + excelhandle.date), 'Hi All \n 今天Jira问题汇总已采集,参见附件 \n 本邮件由系统自动推送,勿需回复 \n 以上 \n 谢谢', ["..\\KdIssueCollect.xlsx"])
else:
mailsender.SendMail(MailList, str(u'凯迪智能装备事业部开发问题汇总-' + excelhandle.date), 'Hi All \n 今天Jira问题汇总已采集,参见附件 \n 本邮件由系统自动推送,勿需回复 \n 以上 \n 谢谢', ["../KdIssueCollect.xlsx"])
if len(developList) > 0:
if iswin:
excelhandle = KDExcel("..\\developIssue.xlsx")
else:
excelhandle = KDExcel("../developIssue.xlsx")
excelhandle.dealData(developList, "Develop")
excelhandle.close()
if iswin:
mailsender.SendMail(DevelopMail, str(u'开发问题汇总-' + excelhandle.date), 'Hi All \n 今天Jira开发内建问题汇总已采集,参见附件 \n 本邮件由系统自动推送,勿需回复 \n 以上 \n 谢谢', ["..\\developIssue.xlsx"])
else:
mailsender.SendMail(DevelopMail, str(u'开发问题汇总-' + excelhandle.date), 'Hi All \n 今天Jira开发内建问题汇总已采集,参见附件 \n 本邮件由系统自动推送,勿需回复 \n 以上 \n 谢谢', ["../developIssue.xlsx"])
mailsender.QuitMail()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wjf-osc/loadjiradata2excel.git
git@gitee.com:wjf-osc/loadjiradata2excel.git
wjf-osc
loadjiradata2excel
loadjiradata2excel
master

搜索帮助