예제 #1
0
    def start(self, argv):

        # Set up context
        ctx = Context()
        ctx.argv = argv 
        
        # Parse arguments
        self.parse_args(ctx)
        
        # Init logging
        self.configure_logging(ctx)
        logger = logging.getLogger(__name__)
        logger.info ("Starting %s" % cubetl.APP_NAME_VERSION)
        logger.debug ("Debug logging level enabled")
        
        # TODO: Character encoding considerations? warnings?
        
        
        # Init container
        self.init_container(ctx)
        
        # Init property components
        self.init_properties(ctx)

        # Launch process
        try:
            process = cubetl.container.get_object(ctx.start_node)
        except KeyError, e:
            logger.error ("Start process '%s' not found in configuration" % ctx.start_node)
            sys.exit(1)
예제 #2
0
    def init(self, argv=None, cli=False, debug=False):


        # Set up context
        ctx = Context()
        ctx.argv = argv
        ctx.cli = cli

        if not ctx.cli:
            ctx.argv = []
            ctx.start_node = "_dummy"

        # Set library dir
        # FIXME: Fix this so it works with setup.py/others installatiob
        base_dir = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../../")
        ctx.props['dir_lib'] = base_dir + "/library"

        # Parse arguments
        self.parse_args(ctx)

        ctx.debug = debug

        # Init logging
        self.configure_logging(ctx)
        logger = logging.getLogger(__name__)
        logger.info("Starting %s" % cubetl.APP_NAME_VERSION)
        logger.debug("Debug logging level enabled")

        # TODO: Character encoding considerations? warnings?


        # Init container (reads config)
        self.init_container(ctx)

        return ctx
예제 #3
0
    def init(self, argv=None, cli=False, debug=False):

        # Set up context
        ctx = Context()
        ctx.argv = argv
        ctx.cli = cli

        if not ctx.cli:
            ctx.argv = []
            ctx.start_nodes = ["_dummy"]

        # Set library dir
        # FIXME: Fix this so it works with setup.py/others installatiob
        base_dir = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../../")
        ctx.props['dir_lib'] = base_dir + "/library"

        ctx.debug = debug

        # Parse arguments
        self.parse_args(ctx)

        # Init logging
        self.configure_logging(ctx)
        logger = logging.getLogger(__name__)
        logger.info("Starting %s" % cubetl.APP_NAME_VERSION)
        logger.debug("Debug logging level enabled")

        # TODO: Character encoding considerations? warnings?

        # Load default config
        self.default_config(ctx)

        return ctx
예제 #4
0
    def start(self, argv):

        # Set up context
        ctx = Context()
        ctx.argv = argv

        # Set library dir
        # FIXME: Fix this so it works with setup.py/others installatiob
        base_dir = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../../")
        ctx.props['dir_lib'] = base_dir + "/library"

        # Parse arguments
        self.parse_args(ctx)

        # Init logging
        self.configure_logging(ctx)
        logger = logging.getLogger(__name__)
        logger.info("Starting %s" % cubetl.APP_NAME_VERSION)
        logger.debug("Debug logging level enabled")

        # TODO: Character encoding considerations? warnings?


        # Init container (reads config)
        self.init_container(ctx)

        # Launch process
        try:
            process = cubetl.container.get_component_by_id(ctx.start_node)
        except KeyError as e:
            logger.error("Start process '%s' not found in configuration" % ctx.start_node)
            sys.exit(1)

        count = 0

        # Launch process and consume messages
        try:
            logger.debug("Initializing components")
            ctx.comp.initialize(process)

            logger.info("Processing %s" % ctx.start_node)

            if ctx.profile:
                logger.warning("Profiling execution (WARNING this is SLOW) and saving results to: %s" % ctx.profile)
                cProfile.runctx("count = self._do_process(process, ctx)", globals(), locals(), ctx.profile)
            else:
                count = self._do_process(process, ctx)

            logger.debug("%s messages resulted from the process" % count)

            logger.debug("Finalizing components")
            ctx.comp.finalize(process)

            ctx.comp.cleanup()

        except KeyboardInterrupt as e:
            logger.error("User interrupted")

        except Exception as e:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            logger.fatal("Error during process: %s" % ", ".join((traceback.format_exception_only(exc_type, exc_value))))

            if hasattr(ctx, "eval_error_message"):
                pp = pprint.PrettyPrinter(indent=4, depth=2)
                print pp.pformat(ctx._eval_error_message)

            traceback.print_exception(exc_type, exc_value, exc_traceback)