Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tarraschk authored Dec 1, 2024
1 parent 68fb8f6 commit 2363370
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@ def fetch_alerts():
return response.json()

def fetch_alert_details(json_url):
time.sleep(5)
base_url = "https://www.cert.ssi.gouv.fr"
full_url = base_url + json_url
logging.info(f"Fetching alert details from {full_url}")
response = requests.get(full_url)
response.raise_for_status()
retries = 3
for attempt in range(retries):
try:
response = requests.get(full_url)
response.raise_for_status()
break
except requests.RequestException as e:
logging.error(f"Attempt {attempt + 1} failed: {e}")
if attempt < retries - 1:
time.sleep(5*(attempt + 1))
else:
raise
logging.info(f"Successfully fetched details for {json_url}")
return response.json()

Expand Down

0 comments on commit 2363370

Please sign in to comment.