1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| import time import os from collections import Counter from jira import JIRA from datetime import datetime
# The notifier function def run_once(f): def wrapper(*args, **kwargs): if not wrapper.has_run: wrapper.has_run = True return f(*args, **kwargs) wrapper.has_run = False return wrapper
def notify(title, subtitle, message): t = '-title {!r}'.format(title) s = '-subtitle {!r}'.format(subtitle) m = '-message {!r}'.format(message) v = '-sound glass' os.system('terminal-notifier {}'.format(' '.join([m, t, s, v])))
def timer(n): print("初始化") print("开始监测工单...") jira = JIRA('你的jira服务器地址',basic_auth=('用户名', '密码')) while True: tickets = jira.search_issues('The JQL for search jira ticket,搜索工单的jql') for issue in tickets: # jira.assign_issue(issue, '需要assign的用户名') print('{},{},{},{},{}'.format(issue.key,issue.fields.creator,issue.fields.summary,str(issue.fields.customfield_10208),issue.fields.priority.name)) notify(title = 'JIRA', subtitle = issue.key, message = issue.fields.summary) jira.assign_issue(issue, '需要assign的用户名') time.sleep(n) timer(120)
|