本问介绍如何通过python实现Bugzilla Web Service的调用。
关于Bugzilla web service的介绍,可以参考其官方文档:WebService API Reference
Bugzilla web service获取/发送数据的方式是通过http Get/Put/Post实现的,所以我们先通过python实现http Get/Put/Post功能:
#encoding=utf-8
#common.py
from functools import wraps
import traceback
import requests
import json
def RequestGetDecorator(func):
'''
bug rest request get decorator
'''
@wraps(func)
def wrapper(*args, **kwargs):
req,params = func(*args, **kwargs)
retry_count = 3
while retry_count>0:
try:
res = requests.get(req, params=params, timeout=300)
break
except requests.exceptions.ReadTimeout:
print("retry:", retry_count)
retry_count -= 1