예제 #1
0
    def __init__(self, init_all=True, executor=True):
        """Initializes a new Context object. This acts as an interface for objects to access other event specific
            variables that might be needed.
        """
        try:
            self.execution_db = walkoff.executiondb.ExecutionDatabase(
                walkoff.config.Config.EXECUTION_DB_TYPE,
                walkoff.config.Config.EXECUTION_DB_PATH,
                walkoff.config.Config.EXECUTION_DB_HOST)
        except OperationalError as e:
            if "password" in str(e):
                logger.error(
                    "Incorrect username and/or password for execution database. Please make sure these are "
                    "both set correctly in their respective environment variables and try again."
                    "Error Message: {}".format(str(e)))
            else:
                logger.error(
                    "Error connecting to execution database. Please make sure all database settings are "
                    "correct and try again. Error Message: {}".format(str(e)))
            os._exit(1)

        if init_all:
            self.cache = walkoff.cache.make_cache(walkoff.config.Config.CACHE)
            if executor:
                import walkoff.multiprocessedexecutor.multiprocessedexecutor as executor
                self.executor = executor.MultiprocessedExecutor(
                    self.cache, walkoff.config.Config)
                self.scheduler = walkoff.scheduler.Scheduler()
예제 #2
0
    def setUpClass(cls):
        initialize_test_config()
        execution_db_help.setup_dbs()

        app = create_app(walkoff.config.Config)
        cls.context = app.test_request_context()
        cls.context.push()

        multiprocessedexecutor.MultiprocessedExecutor.initialize_threading = mock_initialize_threading
        multiprocessedexecutor.MultiprocessedExecutor.wait_and_reset = mock_wait_and_reset
        multiprocessedexecutor.MultiprocessedExecutor.shutdown_pool = mock_shutdown_pool
        cls.executor = multiprocessedexecutor.MultiprocessedExecutor(
            MockRedisCacheAdapter(), create_autospec(CaseLogger))
        cls.executor.initialize_threading(app)
예제 #3
0
    def setUpClass(cls):
        initialize_test_config()
        execution_db_help.setup_dbs()

        app = create_app()
        cls.context = app.test_request_context()
        cls.context.push()

        multiprocessedexecutor.MultiprocessedExecutor.initialize_threading = mock_initialize_threading
        multiprocessedexecutor.MultiprocessedExecutor.wait_and_reset = mock_wait_and_reset
        multiprocessedexecutor.MultiprocessedExecutor.shutdown_pool = mock_shutdown_pool
        cls.executor = multiprocessedexecutor.MultiprocessedExecutor(
            MockRedisCacheAdapter(), LocalActionExecutionStrategy())
        cls.executor.initialize_threading(app)
예제 #4
0
파일: context.py 프로젝트: pir8aye/WALKOFF
    def __init__(self, config):
        """Initializes a new Context object. This acts as an interface for objects to access other event specific
            variables that might be needed.

        Args:
            config (Config): A config object
        """
        self.execution_db = walkoff.executiondb.ExecutionDatabase(
            config.EXECUTION_DB_TYPE, config.EXECUTION_DB_PATH)
        self.case_db = walkoff.case.database.CaseDatabase(
            config.CASE_DB_TYPE, config.CASE_DB_PATH)

        self.subscription_cache = SubscriptionCache()
        self.case_logger = CaseLogger(self.case_db, self.subscription_cache)
        self.cache = walkoff.cache.make_cache(config.CACHE)
        self.executor = executor.MultiprocessedExecutor(
            self.cache, self.case_logger)
        self.scheduler = walkoff.scheduler.Scheduler(self.case_logger)