in libmozdata/bugzilla.py [0:0]
def put(self, data, attachment=False, retry_on_failure=False):
"""Put some data in bugs
Args:
data (dict): a dictionary
"""
failures = []
if self.bugids:
if self.__is_bugid():
ids = self.bugids
else:
ids = self.__get_bugs_list()
url = Bugzilla.ATTACHMENT_API_URL if attachment else Bugzilla.API_URL
url += "/"
to_retry = ids
header = self.get_header()
def cb(data, res, *args, **kwargs):
error = True
if res.status_code == 200:
json = res.json()
if not json.get("error", False):
error = False
if error:
if retry_on_failure:
to_retry.extend(data)
else:
failures.extend(data)
while to_retry:
_to_retry = list(to_retry)
to_retry = []
for _ids in Connection.chunks(
_to_retry, chunk_size=Bugzilla.BUGZILLA_CHUNK_SIZE
):
first_id = _ids[0]
if len(_ids) >= 2:
data["ids"] = _ids
elif "ids" in data:
del data["ids"]
self.session.put(
url + first_id,
json=data,
headers=header,
verify=True,
timeout=self.TIMEOUT,
hooks={"response": functools.partial(cb, _ids)},
).result()
return failures