阅读redmine的最新评论

问题描述 投票:0回答:1

我有一个代码可以连接到redmine,下载一个excel文件,解析要在远程服务器上执行的命令。总共有13条命令要执行。在执行下一条命令之前,我必须先通过“ ok”符号获得客户的确认。我希望该脚本在redmine上听最后的评论,并在客户写“ ok”时执行命令。

目前,如果我能给自己输入信息,我就能做到。 I.E这是代码:


import sys
import requests
from redminelib import Redmine
from dts_viraj_EC40 import get_attachment
from dts_viraj_EC40 import format_file
from bs4 import BeautifulSoup

get_attachment.get_excel()

format_file.parse_excel_sheet()
format_file.file_crop()
format_file.delete_lines()

url = 'http://xxxxxx/issues/4'


count=0

while True:
     # open with GET method
     resp = requests.get(url)
     html_content = resp.text
     soup = BeautifulSoup(html_content, 'html.parser')
     y = soup.find_all("div", {"class": "wiki"})
     result = y[-1].text
     # print(y[-1].text)
     operation=input(result)





     if operation == "ok" or operation == "OK":
        with open("/home/mufit/dts_com") as execute:
          l = execute.readlines()
          print(l[count])

     count += 1

     if count == 13:
        print("script done")
        break

此代码,打印来自redmine的最后评论,并问我来自终端的用户输入。如果我键入“确定”或“确定”,则打印要执行的命令。像这个例子一样:

okok
/custom/app/viraj-batch-database/bin/EC40.sh /custom/data/mustt/mission_22032019/EC40_T_6257294_PPCLI.PLU92F10

okok
/custom/app/viraj-batch-database/bin/EC40.sh /custom/data/mustt/mission_22032019/EC40_T_6298362_PPCLI.PLU92F10

第一个“ ok”是最后一个redmine注释,第二个是我在终端上键入的内容,然后给了我适当的命令。

我想要,脚本从redmine自动获取此输入;每次客户在redmine中添加“ ok”注释时,脚本将打印相应的命令,否则将给出错误消息并退出程序。

how script works

redmine last comment

python python-3.x redmine
1个回答
0
投票

使用以下代码可以解决您的问题,它来自redmine的网站。

GET /issues/[id].xml?include=journals
GET /issues/[id].json?include=journals

wiki from redmine

© www.soinside.com 2019 - 2024. All rights reserved.