乾貨,呼叫api獲取禪道需求列表等

2021-09-13 01:10:06 字數 2192 閱讀 3743

最近有用到開源版的禪道系統,版本10.0,為了更方便地獲取禪道資訊,我參照官方的說明寫了禪道api呼叫的指令碼。由於網上能搜到的部落格基本沒有,我就把自己的成果分享一下。在此申明,此文章內容是我自己原創,並不涉及公司機密,同時請各位請尊重我的勞動成果。

廢話不多說,直接上**再解釋吧。

import requests

import json

class zentao_cli(object):

session = none #用於實現單例類,避免多次申請sessionid

sid = none

def __init__(self, url, account, password, override = false):

self.url = url

self.account = account #賬號

self.password = password #密碼

self.session_override = override #是否覆蓋原會話

self.pages = &password=&sid=", #登入的介面

"get_story_list_by_projectid": "/index.php?t=json&m=story&f=ajaxgetprojectstories&projectid=",

"get_story_list_by_account": "/index.php?"

}self.s = none

self.sid = none

def req(self,url):

#請求並返回結果

web = self.s.get(url)

if web.status_code == 200:

resp = json.loads(web.content)

if resp.get("status") == "success":

return true, resp

else:

return false, resp

def login(self):

if self.s is none:

if not self.session_override and zentao_cli.session is not none:

self.s = zentao_cli.session

self.sid = zentao_cli.sid

else:

#新建會話

self.s = requests.session()

res, resp = self.req(self.url.rstrip("/") + self.pages["sid"])

if res:

print("獲取sessionid成功")

self.sid = json.loads(resp["data"])["sessionid"]

zentao_cli.sid = self.sid

login_res, login_resp = self.req(self.url.rstrip("/") + self.pages["login"].format(self.account, self.password, self.sid))

if login_res:

print("登入成功")

zentao_cli.session = self.s

def get_story_list_by_projectid(self, projectid):

#根據projectid獲取需求列表

req_url = self.url.rstrip("/") + self.pages["get_story_list_by_projectid"].format(str(projectid))

web = self.s.get(req_url)

if web.status_code == 200:

resp = json.loads(web.content.decode())

for k,v in resp.items():

print(k,v)

if __name__ == "__main__":

cli = zentao_cli("", "******", "******123")

cli.login()

cli.get_story_list_by_projectid(17)

api 二次 開發 禪道 測試工具Jira和禪道

jira和禪道是兩款做專案管理的軟體,功能豐富,涵蓋面廣。jira主要功能 scrum板 敏捷團隊可專注於盡可能快速地交付迭代和增量價值。看板 全面了解後續工作事宜,從而讓您可以在最少的週期時間內持續交付最多的輸出 路線圖 描繪專案整體概況 敏捷報告 借助數十種開箱即用的報告,團隊可以實時了解成員在...

Python呼叫API獲取天氣

此程式需要easygui模組,請使用pip install easygui 已知天氣 獲取天氣介面為 城市名,你知道 咋寫嗎?匯入包 from requests import get from easygui import enterbox,msgbox 獲取今天天氣的函式 defgettoday ...

禪道之需求追蹤和多角色協作流程

v5.7沒有完成的需求是不是應該包含在v5.7.2中?v5.7.2發版的時候也會帶上v5.7還沒有發版但是已經開發完成的需求,怎麼區分哪些是v5.7已經發版的需求,哪些是沒有發版但是已經開發完成的需求?需求開發完成並且測試完畢後,產品經理如何發現待驗證的需求?狀態字段 階段字段來跟蹤需求的變化的。圖...