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


Python command.Trigger类代码示例

本文整理汇总了Python中pyasm.command.Trigger的典型用法代码示例。如果您正苦于以下问题:Python Trigger类的具体用法?Python Trigger怎么用?Python Trigger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: execute

    def execute(my):

        process = my.input.get("process")
        sobject = my.input.get("sobject")
        pipeline = my.input.get("pipeline")

        process_obj = pipeline.get_process(process)
        node_type = process_obj.get_type()

        print "Revise: ", process, node_type

        my.run_callback(pipeline, process, "revise")

        if node_type in ['manual', 'node']:
            my.set_all_tasks(sobject, process, "revise")
        if node_type in ['action']:
            my.set_all_tasks(sobject, process, "revise")

        if node_type in ['approval','action','condition']:

            input_processes = pipeline.get_input_processes(process)
            for input_process in input_processes:
                input_process = input_process.get_name()

                input = {
                    'pipeline': pipeline,
                    'sobject': sobject,
                    'process': input_process
                }

                event = "process|revise"
                Trigger.call(my, event, input)
开发者ID:nuxping,项目名称:TACTIC,代码行数:32,代码来源:workflow.py

示例2: handle_revise

    def handle_revise(my):

        my.log_message(my.sobject, my.process, "revise")
        my.run_callback(my.pipeline, my.process, "revise")
        # set all tasks in the process to revise
        my.set_all_tasks(my.sobject, my.process, "revise")

        process_obj = pipeline.get_process(my.process)

        # send revise single to previous processes
        input_processes = pipeline.get_input_processes(my.process)
        for input_process in input_processes:
            input_process = input_process.get_name()

            if my.process_parts:
                input_process = "%s.%s" % (my.process_parts[0], input_process)


            input = {
                'pipeline': my.pipeline,
                'sobject': my.sobject,
                'process': input_process
            }

            event = "process|revise"
            Trigger.call(my, event, input)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:26,代码来源:workflow.py

示例3: _test_js

    def _test_js(my):
        # create a dummy sobject
        sobject = SearchType.create("sthpw/virtual")
        sobject.set_value("code", "test")

        # simple condition
        pipeline_xml = '''
        <pipeline>
          <process type="action" name="a"/>
        </pipeline>
        '''
        pipeline, processes = my.get_pipeline(pipeline_xml)

        process = processes.get("a")
        process.set_json_value("workflow", {
            'cbjs_action': '''
            console.log("This is javascript");
            console.log(input);
            return false
            '''
        } )
        process.commit()


        process = "a"
        output = {
            "pipeline": pipeline,
            "sobject": sobject,
            "process": process,
            "status": "pending"
        }

        import time
        start = time.time()
        Trigger.call(my, "process|pending", output)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:35,代码来源:workflow_test.py

示例4: _test_manual

    def _test_manual(my):

        print "test manual"

        # create a dummy sobject
        sobject = SearchType.create("sthpw/virtual")
        sobject.set_value("code", "test")
        sobject.set_value("a", False)
        sobject.set_value("b", False)


        pipeline_xml = '''
        <pipeline>
          <process name="a"/>
          <process type="action" name="b"/>
          <connect from="a" to="b"/>
        </pipeline>
        '''

        pipeline, processes = my.get_pipeline(pipeline_xml)

        # Run the pipeline
        process = "a"
        output = {
            "pipeline": pipeline,
            "sobject": sobject,
            "process": process
        }
        Trigger.call(my, "process|pending", output)

        # nothing should have run
        my.assertEquals( "pending", sobject.get_value("a"))
        my.assertEquals( False, sobject.get_value("b"))
开发者ID:jayvdb,项目名称:TACTIC,代码行数:33,代码来源:workflow_test.py

示例5: handle_complete

    def handle_complete(my):
 
        # run a nodes complete trigger
        status = "complete"
        my.log_message(my.sobject, my.process, status)
        my.run_callback(my.pipeline, my.process, status)

        process_obj = my.pipeline.get_process(my.process)

        # call the process|pending event for all output processes
        output_processes = my.pipeline.get_output_processes(my.process)
        for output_process in output_processes:
            output_process = output_process.get_name()

            if my.process_parts:
                output_process = "%s.%s" % (my.process_parts[0], output_process)

            output = {
                'pipeline': my.pipeline,
                'sobject': my.sobject,
                'process': output_process
            }

            event = "process|pending"
            Trigger.call(my, event, output)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:25,代码来源:workflow.py

示例6: execute

    def execute(my):
        process = my.input.get("process")
        sobject = my.input.get("sobject")
        pipeline = my.input.get("pipeline")

        process_obj = pipeline.get_process(process)
        node_type = process_obj.get_type()

        my.run_callback(pipeline, process, "revise")

        if node_type in ["condition", "action", "approval"]:

            my.set_all_tasks(sobject, process, "")

            input_processes = pipeline.get_input_processes(process)
            for input_process in input_processes:
                input_process = input_process.get_name()

                input = {
                    'pipeline': pipeline,
                    'sobject': sobject,
                    'process': input_process
                }

                event = "process|revise"
                Trigger.call(my, event, input)


        else:
            my.set_all_tasks(sobject, process, my.get_status())
开发者ID:jayvdb,项目名称:TACTIC,代码行数:30,代码来源:workflow.py

示例7: _test_multi_input

    def _test_multi_input(my):

        # Disabled for now
        return

        # create a dummy sobject
        sobject = SearchType.create("sthpw/virtual")
        code = "test%s" % Common.generate_alphanum_key()
        sobject.set_value("code", code)


        #search = Search("sthpw/message")
        #sobjects = search.get_sobjects()
        #for sobject in sobjects:
        #    sobject.delete()



        # simple condition
        pipeline_xml = '''
        <pipeline>
          <process type="action" name="a"/>
          <process type="action" name="b1"/>
          <process type="action" name="b2"/>
          <process type="action" name="b3"/>
          <process type="action" name="b4"/>
          <process type="action" name="c"/>
          <process type="action" name="d"/>
          <connect from="a" to="b1"/>
          <connect from="a" to="b2"/>
          <connect from="a" to="b3"/>
          <connect from="a" to="b4"/>
          <connect from="b1" to="c"/>
          <connect from="b2" to="c"/>
          <connect from="b3" to="c"/>
          <connect from="b4" to="c"/>
          <connect from="c" to="d"/>
        </pipeline>
        '''
        pipeline, processes = my.get_pipeline(pipeline_xml)


        process = processes.get("c")
        process.set_json_value("workflow", {
            'on_action': '''
            print "c: running action"
            '''
        } )
        process.commit()


        # Run the pipeline
        process = "a"
        output = {
            "pipeline": pipeline,
            "sobject": sobject,
            "process": process
        }
        Trigger.call(my, "process|pending", output)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:59,代码来源:workflow_test.py

示例8: _test_choice

    def _test_choice(my):

        # create a dummy sobject
        sobject = SearchType.create("sthpw/virtual")
        sobject.set_value("code", "test")
        sobject.set_value("a", False)
        sobject.set_value("b", False)
        sobject.set_value("c", False)
        sobject.set_value("d", False)
        sobject.set_value("e", False)


        pipeline_xml = '''
        <pipeline>
          <process type="action" name="a"/>
          <process type="condition" name="b"/>
          <process type="action" name="c"/>
          <process type="action" name="d"/>
          <process type="action" name="e"/>
          <connect from="a" to="b"/>
          <connect from="b" to="c" from_attr="stream1"/>
          <connect from="b" to="d" from_attr="stream2"/>
          <connect from="b" to="e" from_attr="stream3"/>
        </pipeline>

        '''

        pipeline, processes = my.get_pipeline(pipeline_xml)

        process = processes.get("b")
        process.set_json_value("workflow", {
            'on_action': '''
            # ... some code to determine True or False
            return ['stream1', 'stream3']
            ''',
            'on_complete': '''
            sobject.set_value('b', "complete")
            '''
        } )
        process.commit()


        # Run the pipeline
        process = "a"
        output = {
            "pipeline": pipeline,
            "sobject": sobject,
            "process": process
        }
        Trigger.call(my, "process|pending", output)

        my.assertEquals( "complete", sobject.get_value("a"))
        my.assertEquals( "complete", sobject.get_value("b"))
        my.assertEquals( "complete", sobject.get_value("c"))
        my.assertEquals( False, sobject.get_value("d"))
        my.assertEquals( "complete", sobject.get_value("e"))
开发者ID:jayvdb,项目名称:TACTIC,代码行数:56,代码来源:workflow_test.py

示例9: _test_hierarchy

    def _test_hierarchy(my):

        # create a dummy sobject
        sobject = SearchType.create("unittest/person")

        pipeline_xml = '''
        <pipeline>
          <process type="action" name="a"/>
          <process type="hierarchy" name="b"/>
          <process type="action" name="c"/>
          <connect from="a" to="b"/>
          <connect from="b" to="c"/>
        </pipeline>
        '''
        pipeline, processes = my.get_pipeline(pipeline_xml)
        parent_process = processes.get("b")
        print "parent: ", pipeline.get_code()

        sobject.set_value("pipeline_code", pipeline.get_code())
        sobject.commit()

        # create the sub pipeline
        subpipeline_xml = '''
        <pipeline>
          <process type="action" name="suba"/>
          <process type="action" name="subb"/>
          <process type="action" name="subc"/>
          <connect from="suba" to="subb"/>
          <connect from="subb" to="subc"/>
        </pipeline>
        '''
        subpipeline, subprocesses = my.get_pipeline(subpipeline_xml)
        subpipeline.set_value("parent_process", parent_process.get_code())
        subpipeline.commit()
        print "sub: ", subpipeline.get_code()



        # Run the pipeline
        process = "a"
        output = {
            "pipeline": pipeline,
            "sobject": sobject,
            "process": process
        }
        Trigger.call(my, "process|pending", output)

        my.assertEquals( "complete", sobject.get_value("a"))
        my.assertEquals( "complete", sobject.get_value("b"))
        my.assertEquals( "complete", sobject.get_value("c"))
        my.assertEquals( "complete", sobject.get_value("suba"))
        my.assertEquals( "complete", sobject.get_value("subb"))
        my.assertEquals( "complete", sobject.get_value("subc"))
开发者ID:nuxping,项目名称:TACTIC,代码行数:53,代码来源:workflow_test.py

示例10: handle_pending

    def handle_pending(my):

        # DISABLE for now
        #if not my.check_inputs():
        #    return

        # simply calls action
        my.log_message(my.sobject, my.process, "pending")
        my.set_all_tasks(my.sobject, my.process, "pending")
        my.run_callback(my.pipeline, my.process, "pending")

        Trigger.call(my, "process|action", output=my.input)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:12,代码来源:workflow.py

示例11: _test_multi_input

    def _test_multi_input(self):

        # create a dummy sobject
        sobject = SearchType.create("sthpw/virtual")
        code = "test%s" % Common.generate_alphanum_key()
        sobject.set_value("code", code)



        # simple condition
        pipeline_xml = '''
        <pipeline>
          <process type="action" name="a"/>
          <process type="action" name="b1"/>
          <process type="action" name="b2"/>
          <process type="action" name="b3"/>
          <process type="action" name="b4"/>
          <process type="action" name="c"/>
          <process type="action" name="d"/>
          <connect from="a" to="b1"/>
          <connect from="a" to="b2"/>
          <connect from="a" to="b3"/>
          <connect from="a" to="b4"/>
          <connect from="b1" to="c"/>
          <connect from="b2" to="c"/>
          <connect from="b3" to="c"/>
          <connect from="b4" to="c"/>
          <connect from="c" to="d"/>
        </pipeline>
        '''
        pipeline, processes = self.get_pipeline(pipeline_xml)


        process = processes.get("c")
        process.commit()

        # Run the pipeline
        process = "a"
        output = {
            "pipeline": pipeline,
            "sobject": sobject,
            "process": process
        }
        Trigger.call(self, "process|pending", output)
       
        self.assertEquals( "complete", sobject.get_value("a"))
        self.assertEquals( "complete", sobject.get_value("b1"))
        self.assertEquals( "complete", sobject.get_value("b2"))
        self.assertEquals( "complete", sobject.get_value("b3"))
        self.assertEquals( "complete", sobject.get_value("b4"))
        self.assertEquals( "complete", sobject.get_value("c"))
        self.assertEquals( "complete", sobject.get_value("d"))
开发者ID:mincau,项目名称:TACTIC,代码行数:52,代码来源:workflow_test.py

示例12: add

    def add(key, cache):
        CACHE[key] = cache

        # when adding a new event, register its events
        events = cache.get_refresh_events()

        from pyasm.command import Trigger
        for event in events:
            #print "registering: ", event
            trigger = SearchType.create("sthpw/trigger")
            trigger.set_value("event", event)
            trigger.set_value("class_name", "pyasm.command.SearchTypeCacheTrigger")
            Trigger.append_static_trigger(trigger)
开发者ID:mincau,项目名称:TACTIC,代码行数:13,代码来源:cache.py

示例13: execute

    def execute(my):

        web = WebContainer.get_web()
        
        # get the input names
        input_names = web.get_form_value(SerialStatusWdg.STATUS_CMD_INPUT).split('|')
        
        values = []
        for input_name in input_names:
            value = web.get_form_value(input_name)
            if value:
                values.append(web.get_form_value(input_name))
            
       
        # FIXME: HARDCODED Value for status column!!!!
        column = "status"

        for value in values:
            # get the sobject to be updated
            search_type,id,status = value.split("|")
            search = Search(search_type)
            search.add_id_filter(id)
            my.sobject = search.get_sobject()
            
            status_attr = my.sobject.get_attr(column)

            cur_status = status_attr.get_current_process()
            if cur_status == status:
                continue

            status_attr.set_status(status)
           
            update_column = 'time_update'
            if update_column in my.sobject.get_attr_names():
                my.sobject.set_value(update_column, Sql.get_timestamp_now(), quoted=False)
            my.sobject.commit()

           
            # if this is successful, the store it in the status_log
            status_log = SObjectFactory.create("sthpw/status_log")
            status_log.set_value("login", Environment.get_user_name() )
            status_log.set_value("search_type", search_type)
            status_log.set_value("search_id", id)
            #status_log.set_value("status", "%s to %s" % (cur_status, status) )
            status_log.commit()
            status_log.set_value("from_status", cur_status)
            status_log.set_value("to_status", status)

            # Call the finaled trigger
            Trigger.call(my, status)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:50,代码来源:serial_status.py

示例14: __init__

    def __init__(self, **kwargs):
        super(TransactionQueueManager, self).__init__(**kwargs)

        trigger = TransactionQueueServersTrigger()
        trigger.execute()
        self.servers = Container.get("TransactionQueueServers")

        # add a static trigger
        event = "change|sthpw/sync_server"
        trigger = SearchType.create("sthpw/trigger")
        trigger.set_value("event", event)
        trigger.set_value("class_name", "tactic.command.TransactionQueueServersTrigger")
        trigger.set_value("mode", "same process,same transaction")
        Trigger.append_static_trigger(trigger, startup=True)
开发者ID:mincau,项目名称:TACTIC,代码行数:14,代码来源:run_transaction_cmd.py

示例15: _test_trigger

    def _test_trigger(my):

        # create a dummy sobject
        sobject = SearchType.create("unittest/person")

        pipeline_xml = '''
        <pipeline>
          <process type="action" name="a"/>
        </pipeline>
        '''
        pipeline, processes = my.get_pipeline(pipeline_xml)

        process = processes.get("a")
        process.set_value("workflow", "")
        process.commit()


        folder = Common.generate_alphanum_key()

        Trigger.clear_db_cache()
        event = "process|action"
        trigger = SearchType.create("config/trigger")
        trigger.set_value("event", event)
        trigger.set_value("process", process.get_code())
        trigger.set_value("mode", "same process,same transaction")
        trigger.set_value("script_path", "%s/process_trigger" % folder)
        trigger.commit()

        script = SearchType.create("config/custom_script")
        script.set_value("folder", folder)
        script.set_value("title", "process_trigger")
        script.set_value("script", '''
        print "---"
        for key, value in input.items():
            print key, value
        print "---"
        print "process: ", input.get("process")
        ''')
        script.commit()
 
        # Run the pipeline
        process = "a"
        output = {
            "pipeline": pipeline,
            "sobject": sobject,
            "process": process
        }
        Trigger.call(my, "process|pending", output)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:48,代码来源:workflow_test.py


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