commons内部修改

commons内部修改
This commit is contained in:
hzk007 2023-12-02 22:21:31 +08:00
commit 975d55de9a
1 changed files with 17 additions and 7 deletions

View File

@ -1,31 +1,41 @@
#!/usr/bin/python
# 负责调用平台接口 完成各项操作
import sys
sys.path.append('..')
import requests
import json
import config.baseConfig as baseconfig
from commons.logUtil import logger
sys.path.append('..') # 将上级目录加入到系统路径中,以便导入那里的模块
import requests # 导入requests库用于发起HTTP请求
import json # 导入json库用于处理JSON数据
import config.baseConfig as baseconfig # 导入配置文件里面可能包含API的基本配置信息
from commons.logUtil import logger # 从commons目录导入日志工具
# 获取 pull状态新信息
def get_pull_infor(owner, repo, index):
# 构造请求的URL
url = baseconfig.apiUrl + "api/v1/{}/pulls/{}.json".format(repo, index)
# 发起GET请求获取Pull请求的信息
response = requests.get(url, headers=baseconfig.header, proxies = baseconfig.proxies)
logger.info("get_pull_infor调用"+str(response.json()))
# 记录日志
logger.info("get_pull_infor调用" + str(response.json()))
# 返回响应的JSON数据
return response.json()
# 获取 添加pull评论信息
def create_pull_comment(issue_id):
# 构造请求的URL
url = baseconfig.apiUrl + "api/issues/{}/journals.json".format(issue_id)
COMMENT = "注意!\n该合并请求已创建满两小时,长时间未处理可能会降低贡献的质量和贡献者积极性。\n请及时处理!"
# 准备请求的数据
data = json.dumps({'content': COMMENT})
# 发起POST请求添加评论
response = requests.post(url, data=data, headers=baseconfig.header, proxies = baseconfig.proxies)
logger.info("create_pull_comment调用"+str(response.json()))
# 记录日志
logger.info("create_pull_comment调用" + str(response.json()))
# 返回响应的JSON数据
return response.json()
if __name__ == '__main__':
# 测试函数使用特定的参数调用get_pull_infor函数
get_pull_infor("wuxiaojun", "wuxiaojun/botreascrch", "3")