当前位置 博文首页 > 我的地盘我做主:【Python】【应用】Python应用之玩转gerrit系列
- windows 7(64bits)
- python 3.8.6
Pygerrit2 is compatible with Python 2.6 and Python 2.7. Support for
Python 3 is experimental.
from requests.auth import HTTPDigestAuth
from pygerrit2.rest import GerritRestAPI
if __name__ == '__main__':
auth = HTTPDigestAuth('qxhgd@xxx.com', 'pwd2qxhgd') #获取auth信息
rest = GerritRestAPI(url='https://gerrit.xxx.com', auth=auth) #用auth信息去访问gerrit的rest接口
changes = rest.get("/changes/?q=owner:self%20status:open") #用rest接口去查询相关信息,json格式返回
print(changes) #将json串打印出来
python -m pip install --upgrade pip #升级pip
pip3 install requests #直接使用官方源安装
pip3 install -i https://pypi.douban.com/simple requests #使用镜像安装requests
pip3 install pygerrit2-i https://pypi.douban.com/simple #使用镜像安装pygerrit2, 用镜像安装可用上述两种格式
如本文对你有些许帮助,欢迎打赏或通过里面链接购买书籍:
支付宝打赏方式及我的购物小店