前沿:最近需要對jira專案中issue的規範性進行檢查,故研究了一下python中的第三方包jira,並在此做以記錄。
pip install jira
下面是乙個快速使用的例子:
1#這個指令碼顯示了如何在匿名模式下使用客戶機2#
網域名稱位址jira.atlassian.com.
3from jira import
jira
4importre5
6#預設情況下,客戶端將連線到從atlassian外掛程式sdk啟動的jira例項。7#
參見: for details8#
使用option引數鏈結服務
9 options =
11 jira =jira(options)
1213
#使用server引數直接鏈結服務,和上述鏈結方式任選一種即可14#
jira = jira(server='')
1516
#匿名許可權下獲取所有能看到的專案
17 projects =jira.projects()
1819
#按照所有專案的key進行排序並只取key中包含大寫字母e的key,然後返回第二個、第三個和第四個key。
20 keys = sorted(filter(lambda x: re.search(r'
e', x), [project.key for project in projects]))[2:5]
2122
#獲得乙個問題
23 issue = jira.issue('
jra-1330')
2425
#26 atl_comments = [comment for comment in
issue.fields.comment.comments
27if re.search(r'
@atlassian.com$
', comment.author.emailaddress)]
2829
#30 jira.add_comment(issue, '
comment text')
3132
#修改已選擇問題的摘要和描述
33issue.update(
34 summary="
i'm different!
", description='
changed the summary to be different.')
3536
#在不傳送更新的情況下更改問題
37 issue.update(notify=false, description='
quiet summary update.')
3839
#你可以像這樣更新整個標籤
40 issue.update(labels=['
aaa', '
bbb'
])4142#
或者修改現有標籤的列表。新標籤是沒有空格的unicode字串
new_text')
44 issue.update(fields=)
4546
#刪除這個問題
47issue.delete()
4849
#將兩個問題進行關聯
50 issue = jira.issue('
jra-1330')
51 issue2 = jira.issue('
xx-23
') #
could also be another instance
52 jira.add_remote_link(issue, issue2)
下面這個例子展示了如何使用jira使用者名稱和密碼進行身份驗證:
1from collections import
counter
2from jira import
jira
34 jira = jira(basic_auth=('
admin
', '
admin
')) #
a username/password tuple56
#獲取此伺服器的可變應用程式屬性(需要支支系統管理員許可權)89
#找到報告人為admin的所有問題
10 issues = jira.search_issues('
assignee=admin')
1112
#在報告人為管理員的報告中,問題最多的三個專案
13 top_three =counter(
14 [issue.fields.project.key for issue in issues]).most_common(3)
下面的例子使用jql對問題進行刪選:
1from collections import
counter
2from jira import
jira
34 jira = jira(basic_auth=('
admin
', '
admin
')) #
a username/password tuple56
#獲取此伺服器的可變應用程式屬性(需要支支系統管理員許可權)89
#獲得滿足篩選條件的問題10#
第乙個條件的作用(專案的key或者id在這個元組中即可)11#
第二個條件的作用是選擇問題的狀態(open:開放,resolved: 已解決,in progress:處理中,reopened:重新開啟,closed:關閉)12#
第三個條件的作用是篩選問題型別為故障13#
第四個條件篩選問題的建立時間在24小時內(y:年,m:月,d:天,h:小時,m:分鐘,s:秒)14#
maxresults的作用是一次獲取多少個問題,預設為50
15 issues_in_proj =jira.search_issues(16'
project in (edb, map, map, nsts, sjzzq, sjzxggyb, sjzd, hsgsshq, pcxt, sjzxybglxt, sjzxfctjr) and status=open and issuetype="故障" and created >= "-24h"',
17 maxresults=100)
對pg buffercache 的利用實驗
先看有沒有髒資料 postgres select isdirty from pg buffercache where isdirty t isdirty 0 rows 此時尚未有髒資料。進一步確認 postgres select count from pg buffercache where isd...
SQLSERVER對索引的利用
寫sql語句的時候很多時候會用到filter篩選掉一些記錄,sql對篩選條件簡稱 sarg search argument sarg 1 where amount 4000 and amount 6000 上面這句就是篩選條件 當然這裡不是說sqlserver的where子句,是說sqlserver...
SQLSERVER對索引的利用
寫sql語句的時候很多時候會用到filter篩選掉一些記錄,sql對篩選條件簡稱 sarg search argument sarg 1 where amount 4000 and amount 6000 上面這句就是篩選條件 當然這裡不是說sqlserver的where子句,是說sqlserver...