# Path: oshino/config.py
# def load(config_file):
#     """
#     Processes and loads config file.
#     """
#     with open(config_file, "r") as f:
# 
#         def env_get():
#             return dict(os.environ)
#         tmpl = Template(f.read())
#         return Config(yaml.safe_load(tmpl.render(**env_get())))
# 
# Path: oshino/core/heart.py
# def start_loop(cfg: Config, noop=False):
#     logger.info("Initializing Oshino v{0}".format(get_version()))
#     logger.info("Running forever in {0} seconds interval. Press Ctrl+C to exit"
#                 .format(cfg.interval))
#     if cfg.sentry_dsn:
#         try:
#             client = SentryClient(cfg.sentry_dsn)
#             logging.root.handlers.append(SentryHandler(client,
#                                           level=logging.ERROR,
#                                           bubble=True))
#         except InvalidDsn:
#             logger.warn("Invalid Sentry DSN '{0}' providen. Skipping"
#                         .format(cfg.sentry_dsn))
# 
# 
#     loop = create_loop()
#     try:
#         loop.run_until_complete(main_loop(cfg,
#                                           cfg.riemann.get_transport(noop),
#                                           forever,
#                                           loop=loop))
#     finally:
#         loop.close()


import logging
from argparse import ArgumentParser
from dotenv import load_dotenv, find_dotenv
from .config import load
from .core.heart import start_loop



logger = logging.getLogger(__name__)


try:
    load_dotenv(find_dotenv())
except Exception as ex:
    logger.error("Error while loading .env: '{}'. Ignoring.".format(ex))


def main(args):
    if args.debug:

# Path: oshino/config.py
# def load(config_file):
#     """
#     Processes and loads config file.
#     """
#     with open(config_file, "r") as f:
# 
#         def env_get():
#             return dict(os.environ)
#         tmpl = Template(f.read())
#         return Config(yaml.safe_load(tmpl.render(**env_get())))
# 
# Path: oshino/core/heart.py
# def start_loop(cfg: Config, noop=False):
#     logger.info("Initializing Oshino v{0}".format(get_version()))
#     logger.info("Running forever in {0} seconds interval. Press Ctrl+C to exit"
#                 .format(cfg.interval))
#     if cfg.sentry_dsn:
#         try:
#             client = SentryClient(cfg.sentry_dsn)
#             logging.root.handlers.append(SentryHandler(client,
#                                           level=logging.ERROR,
#                                           bubble=True))
#         except InvalidDsn:
#             logger.warn("Invalid Sentry DSN '{0}' providen. Skipping"
#                         .format(cfg.sentry_dsn))
# 
# 
#     loop = create_loop()
#     try:
#         loop.run_until_complete(main_loop(cfg,
#                                           cfg.riemann.get_transport(noop),
#                                           forever,
#                                           loop=loop))
#     finally:
#         loop.close()


# Path: oshino/run.py
import logging
from argparse import ArgumentParser
from dotenv import load_dotenv, find_dotenv
from .config import load
from .core.heart import start_loop




logger = logging.getLogger(__name__)


try:
    load_dotenv(find_dotenv())
except Exception as ex:
    logger.error("Error while loading .env: '{}'. Ignoring.".format(ex))


def main(args):
    if args.debug:

        logging.basicConfig(level=logging.DEBUG)