# Path: park_api/env.py
# API_VERSION = '1.0'
# SERVER_VERSION = '0.3.0'
# SOURCE_REPOSITORY = 'https://github.com/offenesdresden/ParkAPI'
# APP_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
# SERVER_CONF = None
# ENV = None
# SUPPORTED_CITIES = None
# DATABASE = {}
# DEFAULT_CONFIGURATION = {
#     "port": 5000,
#     "host": "::1",
#     "debug": False,
#     "live_scrape": True,
#     "database_uri": "postgres:///park_api",
# }
#         SUPPORTED_CITIES = load_cities()
#     ENV = os.getenv("env", "development")
#     SERVER_CONF = structs.ServerConf(host=raw_config.get('host'),
#                                      port=raw_config.getint("port"),
#                                      debug=raw_config.getboolean("debug"))
#     LIVE_SCRAPE = raw_config.getboolean("live_scrape")
#     DATABASE_URI = raw_config.get("database_uri")
#         SERVER_VERSION = '0.3.{0}'.format(rev)
# def is_production():
# def is_development():
# def is_testing():
# def is_staging():
# def load_cities():
# def supported_cities():
# def load_config():
# def determine_server_version():
# 
# Path: park_api/db.py
# POOL = None
#     POOL = ThreadedConnectionPool(1, 20,
#             database=u.path[1:],
#             user=u.username,
#             password=u.password,
#             host=u.hostname,
#             port=u.port)
# def setup(url=env.DATABASE_URI):
# def cursor(commit=False):
# 
# Path: park_api/app.py
# def user_agent(request):
# def init_static():
# def update_cache(city):
# def get_meta():
# def get_api_status():
# def get_lots(city):
# def get_longtime_forecast(city, lot_id):
# def make_coffee():


import logging
import os
from logging.handlers import RotatingFileHandler
from park_api import env, db
from park_api.app import app


def main():
    log_path = os.path.join(env.APP_ROOT, "log", env.ENV + ".log")
    log_handler = RotatingFileHandler(log_path,
                                      maxBytes=1000000,
                                      backupCount=1)
    formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s ")
    log_handler.setFormatter(formatter)

    app.logger.addHandler(log_handler)
    app.logger.addHandler(logging.StreamHandler())

    if not env.is_development():
        app.logger.setLevel(logging.INFO)
        log_handler.setLevel(logging.INFO)


# Path: park_api/env.py
# API_VERSION = '1.0'
# SERVER_VERSION = '0.3.0'
# SOURCE_REPOSITORY = 'https://github.com/offenesdresden/ParkAPI'
# APP_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
# SERVER_CONF = None
# ENV = None
# SUPPORTED_CITIES = None
# DATABASE = {}
# DEFAULT_CONFIGURATION = {
#     "port": 5000,
#     "host": "::1",
#     "debug": False,
#     "live_scrape": True,
#     "database_uri": "postgres:///park_api",
# }
#         SUPPORTED_CITIES = load_cities()
#     ENV = os.getenv("env", "development")
#     SERVER_CONF = structs.ServerConf(host=raw_config.get('host'),
#                                      port=raw_config.getint("port"),
#                                      debug=raw_config.getboolean("debug"))
#     LIVE_SCRAPE = raw_config.getboolean("live_scrape")
#     DATABASE_URI = raw_config.get("database_uri")
#         SERVER_VERSION = '0.3.{0}'.format(rev)
# def is_production():
# def is_development():
# def is_testing():
# def is_staging():
# def load_cities():
# def supported_cities():
# def load_config():
# def determine_server_version():
# 
# Path: park_api/db.py
# POOL = None
#     POOL = ThreadedConnectionPool(1, 20,
#             database=u.path[1:],
#             user=u.username,
#             password=u.password,
#             host=u.hostname,
#             port=u.port)
# def setup(url=env.DATABASE_URI):
# def cursor(commit=False):
# 
# Path: park_api/app.py
# def user_agent(request):
# def init_static():
# def update_cache(city):
# def get_meta():
# def get_api_status():
# def get_lots(city):
# def get_longtime_forecast(city, lot_id):
# def make_coffee():


# Path: park_api/server.py
import logging
import os
from logging.handlers import RotatingFileHandler
from park_api import env, db
from park_api.app import app



def main():
    log_path = os.path.join(env.APP_ROOT, "log", env.ENV + ".log")
    log_handler = RotatingFileHandler(log_path,
                                      maxBytes=1000000,
                                      backupCount=1)
    formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s ")
    log_handler.setFormatter(formatter)

    app.logger.addHandler(log_handler)
    app.logger.addHandler(logging.StreamHandler())

    if not env.is_development():
        app.logger.setLevel(logging.INFO)
        log_handler.setLevel(logging.INFO)


    db.setup()