Python 使用pygerrit从gerrit url获取机器人注释失败
我正在尝试编写一个小应用程序,从gerrit url的内容中提取robot注释:Python 使用pygerrit从gerrit url获取机器人注释失败,python,json,gerrit,Python,Json,Gerrit,我正在尝试编写一个小应用程序,从gerrit url的内容中提取robot注释: rest = GerritRestAPI(url=options.gerrit_url, auth=HTTPDigestAuth(raw_input("username: "), raw_input("Password: ")), verify=True) try: changes = rest.get("gerrit/#/c/{change_id}/robotcomments") logging
rest = GerritRestAPI(url=options.gerrit_url, auth=HTTPDigestAuth(raw_input("username: "), raw_input("Password: ")), verify=True)
try:
changes = rest.get("gerrit/#/c/{change_id}/robotcomments")
logging.info("%d changes", len(changes))
for change in changes:
logging.info(change['change_id'])
except RequestException as err:
logging.error("Error: %s", str(err))
我按照RESTAPI获取机器人评论数据,
由于某种原因,我得到一个404错误,页面不存在。
有人知道如何使用pygerrit从url中获取信息并重新提交吗
在调用rest.get(“gerrit/#/c/{change\u id}/robotcomments”)
时,我尝试了很多对url的添加,或者change/{change\u id}/robotcomments
或者gerrit/#/c/{change_id}/robotcomments
它们都不起作用,我还看到调用rest.get
会在url中添加“a”,所以我尝试使用下面的代码而不是pygerrit:
url = "https/{gerrit_url}/gerrit/#/c/{change_id}/robotcomments"
myResponse = requests.get(url, auth=HTTPDigestAuth(raw_input("username: "), raw_input("Password: ")), verify=True)
print(myResponse.text)
这也是失败的,请让我知道我做错了什么?看看,您似乎应该使用:
rest.get("/changes/{change_id}/robotcomments")
而不是:
rest.get("gerrit/#/c/{change_id}/robotcomments")
正确的URL是:GERRIT-SERVER/a/changes/{change\u id}/robotcomments。“a”是自动添加的,但不要忘记rest.get调用开头的“/”。rest.get(“/changes/{change_id}/robotcomments”)。我在开头有一个GERRIT-SERVER,这里已经提供了:GerritRestAPI(url=options.GERRIT_url,auth=HTTPDigestAuth(原始输入(“用户名”)、原始输入(“密码”)、verify=True)我知道。。。我只是问您是否在rest.get(“/changes/{change\u id}/robotcomments”)调用中的“changes/…”开头添加了“/”。