Moved back to sync and added logging
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import hashlib
|
||||
import httpx
|
||||
import datetime
|
||||
import os
|
||||
@@ -9,13 +8,13 @@ def get_datestring() -> str:
|
||||
return datetime.datetime.now().strftime("%d.%m.%y")
|
||||
|
||||
|
||||
async def cache_cheatsheet(url, outdir: str) -> str | None:
|
||||
def cache_cheatsheet(url, outdir: str) -> str | None:
|
||||
|
||||
print("Caching cheatsheet from", url)
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
r = await client.get(url, timeout=5.0)
|
||||
with httpx.Client() as client:
|
||||
r = client.get(url, timeout=5.0)
|
||||
if not r.is_success and r.headers.get("Content-Type") != "application/pdf":
|
||||
return None
|
||||
except httpx.TimeoutException:
|
||||
|
||||
Reference in New Issue
Block a user