Added more logging
This commit is contained in:
parent
ffa20ea1fc
commit
e4a28d7446
@ -1,14 +1,21 @@
|
||||
from program_schema import ProgramSchema, SUPPORTED_PROGRAM_STRUCTURE_VERSION
|
||||
import requests
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
def load_program(url: str) -> dict:
|
||||
logger = logging.getLogger('loader')
|
||||
headers = {
|
||||
'Accept': 'application/json'
|
||||
'Accept': 'application/json',
|
||||
}
|
||||
logger.debug(f"Performing HTTP request: (url: {url}, headers: {headers})")
|
||||
r = requests.get(url, headers=headers)
|
||||
r.raise_for_status()
|
||||
|
||||
logger.debug(f"HTTP Status: {r.status_code}; Validating downloaded info...")
|
||||
program_schema = ProgramSchema(many=False)
|
||||
program = program_schema.load(r.json()) # Might raise marshmallow exceptions
|
||||
|
||||
return program_schema.load(r.json()) # Might raise marshmallow exceptions
|
||||
logger.info(f"Loaded {program.get('name')} (Created at: {program.get('created_at')}) from {url}")
|
||||
return program
|
||||
|
Loading…
Reference in New Issue
Block a user