# Path: kotori/util/configuration.py
# def read_list(string, separator=u',', empty_elements=True):
#     data = list(map(str.strip, string.split(separator)))
#     if empty_elements == False:
#         data = [x for x in data if bool(x)]
#     return data
# 
# Path: kotori/util/errors.py
# def last_error_and_traceback():
#     error_entry = traceback_get_exception(0)
#     error_last = traceback_get_exception(-1)
#     sep = '-' * 60
#     payload_location = "\n".join([sep, format_exception_location(error_entry, "Entry point:"), sep, format_exception_location(error_last, "Source of exception:")])
#     payload = ''.join(["ERROR: ", error_entry['message'], "\n", payload_location, "\n"])
# 
#     # add full traceback
#     buffer = StringIO()
#     traceback.print_exc(file=buffer)
#     buffer.seek(0)
#     payload += '\n' + buffer.read()
# 
#     return payload
# 
# Path: kotori/util/logger.py
# def changeLogLevel(namespace, loglevel=LogLevel.info):
#     predicate.setLogLevelForNamespace(namespace, loglevel)
# 
# Path: kotori/version.py
# __VERSION__ = '0.26.12'


from pkg_resources import EntryPoint
from pyramid.settings import asbool
from twisted.logger import Logger, LogLevel
from kotori.util.configuration import read_list
from kotori.util.errors import last_error_and_traceback
from kotori.util.logger import changeLogLevel
from kotori.version import __VERSION__
        from kotori.vendor.hydro2motion.database.influx import h2m_boot_influx_database
        from kotori.vendor.hydro2motion.network.udp import h2m_boot_udp_adapter
        from kotori.vendor.hydro2motion.web.server import boot_web
        from kotori.vendor.hiveeyes.application import hiveeyes_boot
        from kotori.vendor.lst.application import lst_boot
                log.info(u'Starting vendor environment for "{vendor}"', vendor=vendor)
                bootloader = getattr(VendorBootloader, vendor)
                try:
                    bootloader(self.settings)
                except Exception as ex:
                    log.failure(
                        'Error booting vendor environment for "{vendor}"":\n{log_failure}"', vendor=vendor)
            else:
                message = 'Vendor environment for "{vendor}" missing.'.format(vendor=vendor)
                log.critical(message)


class VendorBootloader(object):

    @classmethod
    def hydro2motion(cls, settings):

        debug = settings.options.debug
        boot_web(settings, debug=debug)
        h2m_boot_udp_adapter(settings, debug=debug)
        h2m_boot_influx_database(settings)

    @classmethod
    def hiveeyes(cls, settings):
        debug = settings.options.debug
        hiveeyes_boot(settings, debug=debug)

    @classmethod
    def lst(cls, settings):
        debug = settings.options.debug

# Path: kotori/util/configuration.py
# def read_list(string, separator=u',', empty_elements=True):
#     data = list(map(str.strip, string.split(separator)))
#     if empty_elements == False:
#         data = [x for x in data if bool(x)]
#     return data
# 
# Path: kotori/util/errors.py
# def last_error_and_traceback():
#     error_entry = traceback_get_exception(0)
#     error_last = traceback_get_exception(-1)
#     sep = '-' * 60
#     payload_location = "\n".join([sep, format_exception_location(error_entry, "Entry point:"), sep, format_exception_location(error_last, "Source of exception:")])
#     payload = ''.join(["ERROR: ", error_entry['message'], "\n", payload_location, "\n"])
# 
#     # add full traceback
#     buffer = StringIO()
#     traceback.print_exc(file=buffer)
#     buffer.seek(0)
#     payload += '\n' + buffer.read()
# 
#     return payload
# 
# Path: kotori/util/logger.py
# def changeLogLevel(namespace, loglevel=LogLevel.info):
#     predicate.setLogLevelForNamespace(namespace, loglevel)
# 
# Path: kotori/version.py
# __VERSION__ = '0.26.12'


# Path: kotori/core.py
from pkg_resources import EntryPoint
from pyramid.settings import asbool
from twisted.logger import Logger, LogLevel
from kotori.util.configuration import read_list
from kotori.util.errors import last_error_and_traceback
from kotori.util.logger import changeLogLevel
from kotori.version import __VERSION__
        from kotori.vendor.hydro2motion.database.influx import h2m_boot_influx_database
        from kotori.vendor.hydro2motion.network.udp import h2m_boot_udp_adapter
        from kotori.vendor.hydro2motion.web.server import boot_web
        from kotori.vendor.hiveeyes.application import hiveeyes_boot
        from kotori.vendor.lst.application import lst_boot

                log.info(u'Starting vendor environment for "{vendor}"', vendor=vendor)
                bootloader = getattr(VendorBootloader, vendor)
                try:
                    bootloader(self.settings)
                except Exception as ex:
                    log.failure(
                        'Error booting vendor environment for "{vendor}"":\n{log_failure}"', vendor=vendor)
            else:
                message = 'Vendor environment for "{vendor}" missing.'.format(vendor=vendor)
                log.critical(message)


class VendorBootloader(object):

    @classmethod
    def hydro2motion(cls, settings):

        debug = settings.options.debug
        boot_web(settings, debug=debug)
        h2m_boot_udp_adapter(settings, debug=debug)
        h2m_boot_influx_database(settings)

    @classmethod
    def hiveeyes(cls, settings):
        debug = settings.options.debug
        hiveeyes_boot(settings, debug=debug)

    @classmethod
    def lst(cls, settings):
        debug = settings.options.debug

        if settings.options.debug_vendor and 'lst' in read_list(settings.options.debug_vendor):