def handle(self, *args, **options):

        if not options["task_code"]:
            log.error("Expected a task_code argument, use --help.")
            return

        numeric_level = getattr(logging, options["log_level"].upper(), None)
        if not isinstance(numeric_level, int):
            log.error("Invalid log level: %s" % options["log_level"])
            numeric_level = 10

        broker = BrokerConnection()
        connection = broker.connect_to_broker()

        removeFileHandlers()
        setFileHandler(options["worker_nr"])
        setLevelToAllHandlers(numeric_level)

        if connection is None:
            log.error("Could not connect to broker.")
            return

        action = ActionTask(options["task_code"], options["worker_nr"])

        logging.handlers.AMQPMessageHandler = AMQPMessageHandler
        broker_logging_handler = logging.handlers.AMQPMessageHandler(
            action, numeric_level)
        action.set_broker_logging_handler(broker_logging_handler)

        task_worker = Worker(connection, options["task_code"], action,
                             options["worker_nr"])
        task_worker.run_worker()
        removeFileHandlers()
Beispiel #2
0
    def handle(self, *args, **options):

        if not options["queue_code"]:
            log.error("Expected a queue_code argument, use --help.")
            return

        numeric_level = getattr(logging, options["log_level"].upper(), None)
        if not isinstance(numeric_level, int):
            log.error("Invalid log level: %s" % options["log_level"])
            numeric_level = 10

        broker = BrokerConnection()
        connection = broker.connect_to_broker()

        removeFileHandlers()
        setFileHandler(options["worker_nr"])
        setLevelToAllHandlers(numeric_level)

        if connection is None:
            log.error("Could not connect to broker.")
            return

        action = ActionSupervisor(connection, options["queue_code"],
                                  options["worker_nr"], numeric_level)

        logging.handlers.AMQPMessageHandler = AMQPMessageHandler
        broker_logging_handler = logging.handlers.AMQPMessageHandler(
            action, numeric_level)
        action.set_broker_logging_handler(broker_logging_handler)

        task_worker = Worker(connection, options["queue_code"], action,
                             options["worker_nr"])
        log.info("Start worker.")
        task_worker.run_worker()
        removeFileHandlers()
Beispiel #3
0
    def handle(self, *args, **options):
        queue_code = 'logging'

        broker = BrokerConnection()
        connection = broker.connect_to_broker()

        removeFileHandlers()
        setFileHandler('logging')

        if connection is None:
            log.error("Could not connect to broker.")
            return

        action = ActionLogging()

        logging_worker = Worker(connection, queue_code, action)
        log.info("Start logging worker.")
        logging_worker.run_worker()
    def handle(self, *args, **options):
        queue_code = 'logging'

        broker = BrokerConnection()
        connection = broker.connect_to_broker()

        removeFileHandlers()
        setFileHandler('logging')

        if connection is None:
            log.error("Could not connect to broker.")
            return

        action = ActionLogging()

        logging_worker = Worker(connection,
                                queue_code,
                                action)
        log.info("Start logging worker.")
        logging_worker.run_worker()
Beispiel #5
0
    def handle(self, *args, **options):

        numeric_level = getattr(logging, options["log_level"].upper(), None)
        if not isinstance(numeric_level, int):
            log.error("Invalid log level: %s" % options["log_level"])
            numeric_level = 10

        broker = BrokerConnection()
        connection = broker.connect_to_broker()

        removeFileHandlers()
        setFileHandler('queue')

        if connection is None:
            log.error("Could not connect to broker.")
            return
        # TODO CREATE ActionPreority
        action = ActionPriority(connection, options["task_code"])

        queue_worker = Worker(connection, options["task_code"], action)
        queue_worker.run_worker()
    def handle(self, *args, **options):
        """
        Open connection to broker.
        Creates message.
        Creates logging handler to send loggings to broker.
        Sets logging handler to ActionWorkflow object.
        Close connection.
        """
        numeric_level = getattr(logging, options["log_level"].upper(), None)
        if not isinstance(numeric_level, int):
            log.error("Invalid log level: %s" % options["log_level"])
            numeric_level = 10

        broker = BrokerConnection()
        connection = broker.connect_to_broker()

        removeFileHandlers()
        setFileHandler('start')

        if connection is None:
            log.error("Could not connect to broker.")
            return

        action = ActionWorker(connection,
                              options["worker_nr"],
                              options["command"],
                              options["task_code"],
                              options["queue_code"])

        logging.handlers.AMQPMessageHandler = AMQPMessageHandler
        broker_handler = logging.handlers.AMQPMessageHandler(action,
                                                             numeric_level)

        action.set_broker_logging_handler(broker_handler)
        action.execute()

        if connection.is_open:
            connection.close()
Beispiel #7
0
    def handle(self, *args, **options):
        """
        Open connection to broker.
        Creates message.
        Creates logging handler to send loggings to broker.
        Sets logging handler to ActionWorkflow object.
        Close connection.
        """
        numeric_level = getattr(logging, options["log_level"].upper(), None)
        if not isinstance(numeric_level, int):
            log.error("Invalid log level: %s" % options["log_level"])
            numeric_level = 10

        broker = BrokerConnection()
        connection = broker.connect_to_broker()

        removeFileHandlers()
        setFileHandler('start')

        if connection is None:
            log.error("Could not connect to broker.")
            return

        action = ActionWorker(connection, options["worker_nr"],
                              options["command"], options["task_code"],
                              options["queue_code"])

        logging.handlers.AMQPMessageHandler = AMQPMessageHandler
        broker_handler = logging.handlers.AMQPMessageHandler(
            action, numeric_level)

        action.set_broker_logging_handler(broker_handler)
        action.execute()

        if connection.is_open:
            connection.close()
    def handle(self, *args, **options):
        """
        Opens connection to broker.
        Creates ActionWorkflow object.
        Creates logging handler to send loggings to broker.
        Sets logging handler to ActionWorkflow object.
        Performs workflow.
        Closes connection.
        """
        numeric_level = getattr(logging, options["log_level"].upper(), None)
        if not isinstance(numeric_level, int):
            log.error("Invalid log level: %s" % options["log_level"])
            numeric_level = 10

        broker = BrokerConnection()
        connection = broker.connect_to_broker()

        removeFileHandlers()
        setFileHandler('start')

        if connection is None:
            log.error("Could not connect to broker.")
            return

        action = ActionWorkflow(
            connection, options["scenario_id"], options["workflowtemplate_id"])

        logging.handlers.AMQPMessageHandler = AMQPMessageHandler
        broker_handler = logging.handlers.AMQPMessageHandler(action,
                                                             numeric_level)

        action.set_broker_logging_handler(broker_handler)
        action.perform_workflow()

        if connection.is_open:
            connection.close()
    def handle(self, *args, **options):

        numeric_level = getattr(logging, options["log_level"].upper(), None)
        if not isinstance(numeric_level, int):
            log.error("Invalid log level: %s" % options["log_level"])
            numeric_level = 10

        broker = BrokerConnection()
        connection = broker.connect_to_broker()

        removeFileHandlers()
        setFileHandler('queue')

        if connection is None:
            log.error("Could not connect to broker.")
            return
        # TODO CREATE ActionPreority
        action = ActionPriority(connection,
                                options["task_code"])

        queue_worker = Worker(connection,
                              options["task_code"],
                              action)
        queue_worker.run_worker()
    def handle(self, *args, **options):
        """
        Opens connection to broker.
        Creates ActionWorkflow object.
        Creates logging handler to send loggings to broker.
        Sets logging handler to ActionWorkflow object.
        Performs workflow.
        Closes connection.
        """
        numeric_level = getattr(logging, options["log_level"].upper(), None)
        if not isinstance(numeric_level, int):
            log.error("Invalid log level: %s" % options["log_level"])
            numeric_level = 10

        broker = BrokerConnection()
        connection = broker.connect_to_broker()

        removeFileHandlers()
        setFileHandler('start')

        if connection is None:
            log.error("Could not connect to broker.")
            return

        action = ActionWorkflow(connection, options["scenario_id"],
                                options["workflowtemplate_id"])

        logging.handlers.AMQPMessageHandler = AMQPMessageHandler
        broker_handler = logging.handlers.AMQPMessageHandler(
            action, numeric_level)

        action.set_broker_logging_handler(broker_handler)
        action.perform_workflow()

        if connection.is_open:
            connection.close()