Commit 38c32193 authored by Christophe Benz's avatar Christophe Benz
Browse files

Add logging in app initialization

parent ce779265
...@@ -4,12 +4,12 @@ import os ...@@ -4,12 +4,12 @@ import os
from pathlib import Path from pathlib import Path
from urllib.parse import quote_plus from urllib.parse import quote_plus
import cachecontrol
import flask import flask
import jinja2 import jinja2
import requests import requests
import tableschema import tableschema
import cachecontrol
import opendataschema import opendataschema
from . import config from . import config
...@@ -29,17 +29,19 @@ def generate_schema_from_url_func(session): ...@@ -29,17 +29,19 @@ def generate_schema_from_url_func(session):
return schema_from_url return schema_from_url
# And load schema catalogs which urls are found in config.json # And load schema catalogs which URLs are found in homepage_config.json
schema_catalog_map = {} schema_catalog_map = {}
if config.HOMEPAGE_CONFIG: if config.HOMEPAGE_CONFIG:"Initializing homepage sections...")"Initializing homepage sections...")
caching_session = cachecontrol.CacheControl(requests.Session()) caching_session = cachecontrol.CacheControl(requests.Session())
schema_from_url = generate_schema_from_url_func(caching_session) schema_from_url = generate_schema_from_url_func(caching_session)
for section in config.HOMEPAGE_CONFIG['sections']: for section in config.HOMEPAGE_CONFIG['sections']:
code = section['code']'Initializing homepage section "{}"...'.format(code))
if isinstance(section['catalog'], str) and section['catalog'].startswith('http'): if isinstance(section['catalog'], str) and section['catalog'].startswith('http'):
code = section['code']
url = section['catalog'] url = section['catalog']
schema_catalog_map[code] = opendataschema.SchemaCatalog(url, session=caching_session) schema_catalog_map[code] = opendataschema.SchemaCatalog(url, session=caching_session)"...done")
# Flask things # Flask things
app = flask.Flask(__name__) app = flask.Flask(__name__)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment