forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_red.py
More file actions
31 lines (26 loc) · 1.01 KB
/
utils_red.py
File metadata and controls
31 lines (26 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright The IETF Trust 2026, All Rights Reserved
import requests
from django.conf import settings
from ietf.utils.log import log
def trigger_red_precomputer(rfc_number_list=()):
url = getattr(settings, "TRIGGER_RED_PRECOMPUTE_MULTIPLE_URL", None)
if url is not None:
payload = {
"rfcs": ",".join([str(n) for n in rfc_number_list]),
}
try:
log(f"Triggering red precompute multiple for RFCs {rfc_number_list}")
response = requests.post(
url=url,
json=payload,
timeout=settings.DEFAULT_REQUESTS_TIMEOUT,
)
except requests.Timeout as e:
log(f"POST request timed out for {url} : {e}")
return
if response.status_code // 100 != 2: # 2xx status codes are ok
log(
f"POST request failed for {url} : status_code={response.status_code}"
)
else:
log("No URL configured for triggering red precompute multiple, skipping")