MCPcopy Create free account
hub / github.com/adobe/Marinus / make_https_request

Function make_https_request

python3_cron_scripts/download_facebook_certs.py:43–78  ·  view source on GitHub ↗

Utility function so that the script can loop over paged results.

(logger, jobs_manager, fb_url, timeout_attempt=0)

Source from the content-addressed store, hash-verified

41
42
43def make_https_request(logger, jobs_manager, fb_url, timeout_attempt=0):
44 """
45 Utility function so that the script can loop over paged results.
46 """
47 try:
48 req = requests.get(fb_url)
49 req.raise_for_status()
50 except requests.exceptions.ConnectionError:
51 logger.error("FATAL: Connection Error while fetching the cert list")
52 jobs_manager.record_job_error()
53 exit(1)
54 except requests.exceptions.HTTPError:
55 # This occasionally triggers on false domain names
56 # For instance, we are holding .web but it isn't officially recognized yet.
57 # Therefore, Facebook will error on it but it is safe to continue processing.
58 logger.warning("HTTP Error while fetching the cert list")
59 return None
60 except Timeout:
61 if timeout_attempt == 0:
62 logger.warning("Timeout occurred. Attempting again...")
63 result = make_https_request(logger, jobs_manager, fb_url, timeout_attempt=1)
64 return result
65 else:
66 logger.error("FATAL: Too many timeouts. Exiting")
67 jobs_manager.record_job_error()
68 exit(1)
69 except requests.exceptions.RequestException as err:
70 logger.error("FATAL: Request exception while fetching the cert list")
71 logger.error(str(err))
72 jobs_manager.record_job_error()
73 exit(1)
74
75 if req.status_code != 200:
76 return None
77
78 return json.loads(req.text)
79
80
81def fetch_domain(logger, jobs_manager, fbc, access_token, zone):

Callers 1

fetch_domainFunction · 0.70

Calls 1

record_job_errorMethod · 0.80

Tested by

no test coverage detected