コード例 #1
0
 def __init__(self, *args, **kwargs):
     super(TestEngine, self).__init__(*args, **kwargs)
     # Initialize with defaults and to enable linting/ac
     # Test should call _setup_engine() to override any of these attributes
     self.loop = _get_event_loop()
     self.config = config.EngineConfig()
     self.clock = clock.EngineClock(self.config.tz, self.loop)
     self.persist_mgr = persistence.PersistenceManager(
         self.config.json_rules_dir)
     self.enlog = enginelog.EngineLog()
     self.engine_obj = engine.OttoEngine(self.config, self.loop, self.clock,
                                         self.persist_mgr, self.enlog)
コード例 #2
0
    def _setup_engine(self,
                      config_obj: config.EngineConfig = None,
                      loop: asyncio.AbstractEventLoop = None,
                      clock_obj: clock.EngineClock = None,
                      persist_mgr: persistence.PersistenceManager = None,
                      enlog: enginelog.EngineLog = None):
        # These have setup with defautls by the constructor but can be overridden
        # if they are supplied as arguments to this function
        if config_obj:
            self.config = config_obj
        if loop:
            self.loop = loop
        if clock_obj:
            self.clock = clock_obj
        if enlog:
            self.enlog = enlog
        if persist_mgr:
            self.persist_mgr = persistence.PersistenceManager(
                config.json_rules_dir)

        # Always recreate the engine object when this function is called
        self.engine_obj = engine.OttoEngine(self.config, self.loop, self.clock,
                                            self.persist_mgr, self.enlog)
コード例 #3
0
ファイル: run_otto.py プロジェクト: sheaffej/otto-engine
    sys.exit(1)

# Setup the logging
utils.setup_logging(config.log_level)
_LOG = logging.getLogger("run_otto")

# Set Test Websocket to Start if needed
if len(sys.argv) > 1:
    if sys.argv[1].lower() == 'test':
        _LOG.info("Test Websocket server requested by command-line option")
        config.test_websocket_port = 8123

# Initialize the engine
loop = asyncio.get_event_loop()
clock = clock.EngineClock(config.tz, loop=loop)
persistence_mgr = persistence.PersistenceManager(config.json_rules_dir)
engine_log = enginelog.EngineLog()

engine_obj = engine.OttoEngine(config, loop, clock, persistence_mgr,
                               engine_log)

# Start the Flask web server
_LOG.info("Starting web thread")
restapi.engine_obj = engine_obj
web_thread = threading.Thread(target=restapi.run_server)
web_thread.start()

# Start the engine's BaseLoop
engine_obj.start_engine()

# Shutdown the webui