"""Samantha's main module. calling this via 'python samantha'
should start everything else"""
import logging
import Queue

# TODO import only what's necessary
import context
import core
import devices
import logger
import services
import tools


# Initialize the logger
logger.initialize()
LOGGER = logging.getLogger(__name__)


if __name__ == "__main__":
    LOGGER.info("Initializing...")
    LOGGER.debug("-"*47)
    LOGGER.debug("Starting Samantha")
    LOGGER.debug("-"*47)
    LOGGER.info("I'm the main handler.")

    INPUT = Queue.PriorityQueue()
    OUTPUT = Queue.PriorityQueue()

    context.initialize(INPUT, OUTPUT)
    core.initialize(INPUT, OUTPUT)
    devices.initialize(INPUT, OUTPUT)
    services.initialize(INPUT, OUTPUT)
    tools.initialize(INPUT, OUTPUT)

    # TODO
    # load the context
    # Initialize devices and services
    # Start updater as part of tools

    LOGGER.info("Initialisation complete. Opening the Websocket")
    tools.server.run()

    LOGGER.info("Exiting...")
    context.stop()
    devices.stop()
    services.stop()
    tools.stop()
    core.stop()

@@ -961,18 +961,232 @@
 ols.
-server.run
+eventbuilder.Event(sender_id=%22i_main%22,%0A                             keyword=%22onstart%22).trigger()%0A    tools.server.run()%0A%0A    tools.eventbuilder.Event(sender_id=%22i_main%22,%0A                             keyword=%22onexit%22).trigger
 ()%0A%0A

add "onstart" and "onexit" events