forked from Trustie-Study-Group/PRWelBot4SECourse
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
#!/usr/bin/python
|
||
# 负责调用平台接口 完成各项操作
|
||
import sys
|
||
sys.path.append('..')
|
||
import requests
|
||
import json
|
||
import config.baseConfig as baseconfig
|
||
from commons.logUtil import logger
|
||
|
||
|
||
# 获取 pull状态新信息
|
||
def get_pull_infor(owner, repo, index):
|
||
url = baseconfig.apiUrl + "api/v1/{}/pulls/{}.json".format(repo, index)
|
||
response = requests.get(url, headers=baseconfig.header, proxies = baseconfig.proxies)
|
||
logger.info("get_pull_infor调用:"+str(response.json()))
|
||
return response.json()
|
||
|
||
|
||
# 获取 添加pull评论信息
|
||
def create_pull_comment(issue_id):
|
||
url = baseconfig.apiUrl + "api/issues/{}/journals.json".format(issue_id)
|
||
COMMENT = "注意!\n该合并请求已创建满两小时,长时间未处理可能会降低贡献的质量和贡献者积极性。\n请及时处理!"
|
||
data = json.dumps({'content': COMMENT})
|
||
|
||
response = requests.post(url, data=data, headers=baseconfig.header, proxies = baseconfig.proxies)
|
||
logger.info("create_pull_comment调用:"+str(response.json()))
|
||
return response.json()
|
||
|
||
|
||
if __name__ == '__main__':
|
||
get_pull_infor("wuxiaojun", "wuxiaojun/botreascrch", "3")
|