当前位置: 首页>>代码示例>>Python>>正文


Python Pipeline.get_first_process_name方法代码示例

本文整理汇总了Python中pipeline.Pipeline.get_first_process_name方法的典型用法代码示例。如果您正苦于以下问题:Python Pipeline.get_first_process_name方法的具体用法?Python Pipeline.get_first_process_name怎么用?Python Pipeline.get_first_process_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pipeline.Pipeline的用法示例。


在下文中一共展示了Pipeline.get_first_process_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PipelineInterpreter

# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import get_first_process_name [as 别名]
class PipelineInterpreter(object):

    def __init__(self, pipeline_xml, first_process=None):
        self.pipeline_xml = pipeline_xml

        self.first_process = first_process

        self.handlers = []
        self.handlers_dict = {}

        self.package = {}

    def set_server(self, server):
        self.server = server

    def set_package(self, package):
        self.package = package


    def get_handler(self, process_name):
        return self.handlers_dict.get(process_name)

    def get_handlers(self):
        return self.handlers


    def execute(self):
        from pipeline import Pipeline
        self.pipeline = Pipeline(self.pipeline_xml)

        try:
            # if an initial process is not specified, use an implicit one
            if not self.first_process:
                self.first_process = self.pipeline.get_first_process_name()
            self.handle_process(self.first_process)
        except Exception, e:
            if not self.handlers:
                raise
            print("Failed at handler: ", self.handlers[-1])
            try:
                # make a copy and reverse the handlers
                handlers = self.handlers[:]
                handlers.reverse()
                for handler in handlers:
                    handler.undo()
            except Exception, e:
                print("Could not undo:", str(e) )
                raise

            raise
开发者ID:Southpaw-TACTIC,项目名称:TACTIC,代码行数:52,代码来源:interpreter.py

示例2: PipelineInterpreter

# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import get_first_process_name [as 别名]
class PipelineInterpreter(object):

    def __init__(self, pipeline_xml):
        self.pipeline_xml = pipeline_xml

        self.env = AppEnvironment.get()
        self.app = self.env.get_app()
        self.handlers = []
        self.package = {}

    def set_server(self, server):
        self.server = server

    def set_package(self, package):
        self.package = package


    def execute2(self):
        from pipeline import Pipeline
        self.pipeline = Pipeline(self.pipeline_xml)

        try:
            process = self.pipeline.get_first_process_name()
            self.handle_process2(process)
        except Exception, e:
            if not self.handlers:
                raise
            print("Failed at handler: ", self.handlers[-1])
            try:
                # make a copy and reverse the handlers
                handlers = self.handlers[:]
                handlers.reverse()
                for handler in handlers:
                    handler.undo()
            except Exception, e:
                print("Could not undo:", e.__str())
                raise

            raise
开发者ID:Southpaw-TACTIC,项目名称:TACTIC,代码行数:41,代码来源:interpreter.py

示例3: PipelineInterpreter

# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import get_first_process_name [as 别名]
class PipelineInterpreter(object):

    def __init__(self, pipeline_xml):
        self.pipeline_xml = pipeline_xml

        self.env = AppEnvironment.get()
        self.app = self.env.get_app()
        self.handlers = []
        self.package = {}

    def set_server(self, server):
        self.server = server

    def set_package(self, package):
        self.package = package


    def execute2(self):
        from pipeline import Pipeline
        self.pipeline = Pipeline(self.pipeline_xml)

        try:
            process = self.pipeline.get_first_process_name()
            self.handle_process2(process)
        except Exception as e:
            if not self.handlers:
                raise
            print("Failed at handler: ", self.handlers[-1])
            try:
                # make a copy and reverse the handlers
                handlers = self.handlers[:]
                handlers.reverse()
                for handler in handlers:
                    handler.undo()
            except Exception as e:
                print("Could not undo:", e.__str())
                raise

            raise


    def handle_process2(self, process):

        self.pipeline.get_process_info(process)

        # get the handler and instantiate it
        handler_class = self.pipeline.get_handler_class(process)
        if not handler_class:
            return

        try:
            handler = AppEnvironment.create_from_class_path(handler_class)
        except ImportError:
            raise ImportError("Could not import handler class [%s]" % handler_class)
        
        # pass relevant information to the handler
        handler.set_server(self.server)
        handler.set_package(self.package)

        # get input processes and hand over the delivery
        input_processes = self.pipeline.get_input_process_names(process)
        for input_process in input_processes:
            print "input: ", input_process
        #if self.handlers:
        #    handler.set_input( self.handlers[-1].get_output() )


        # store the handler and execute
        self.handlers.append(handler)
        handler.execute()

        # process all of the output handlers
        output_processes = self.pipeline.get_output_process_names(process)
        for output_process in output_processes:
            self.handle_process2(output_process)








   

    def execute(self):

        dom = parseString(self.pipeline_xml)
        root = dom.documentElement
        nodes = root.childNodes

        try:
            for node in nodes:
                node_name = node.nodeName

                if node_name == "process":
                    self.handle_process(node)
                elif node_name == "pipeline":
                    self.handle_process(node)
                elif node_name == "package":
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:interpreter.py


注:本文中的pipeline.Pipeline.get_first_process_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。