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


Python Workflow.complete_all方法代码示例

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


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

示例1: testRunWorkflow

# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import complete_all [as 别名]
    def testRunWorkflow(self):
        filename = os.path.join(os.path.dirname(__file__), 'xml/openwfe/workflow1.xml')
        wf_specs = self.reader.parse_file(filename)
        wf_spec = wf_specs[0]

        for name in wf_spec.task_specs:
            wf_spec.task_specs[name].reached_event.connect(self.on_reached_cb)
            wf_spec.task_specs[name].completed_event.connect(on_complete_cb, self.taken_path)

        workflow = Workflow(wf_spec)
        try:
            workflow.complete_all()
        except:
            workflow.dump()
            raise

        path = [( 1, 'Start'),
                ( 2, 'concurrence_1'),
                ( 3, 'task_a1'),
                ( 4, 'task_a2'),
                ( 5, 'if_condition_1'),
                ( 6, 'task_a3'),
                ( 7, 'if_condition_1_end'),
                ( 8, 'if_condition_2'),
                ( 9, 'task_a5'),
                (10, 'if_condition_2_end'),
                ( 3, 'task_b1'),
                ( 4, 'task_b2'),
                ( 5, 'concurrence_1_end'),
                ( 6, 'task_c1'),
                ( 7, 'task_c2'),
                ( 8, 'End')]

        assert_same_path(self, path, self.taken_path)
开发者ID:filipefigcorreia,项目名称:SpiffWorkflow,代码行数:36,代码来源:OpenWfeXmlReaderTest.py

示例2: runWorkflow

# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import complete_all [as 别名]
    def runWorkflow(self, wf_spec, xml_filename):
        taken_path = []
        for name in wf_spec.task_specs:
            wf_spec.task_specs[name].reached_event.connect(on_reached_cb, taken_path)
            wf_spec.task_specs[name].completed_event.connect(on_complete_cb, taken_path)

        # Execute all tasks within the Workflow
        workflow = Workflow(wf_spec)
        self.assert_(not workflow.is_completed(), "Workflow is complete before start")
        try:
            workflow.complete_all(False)
        except:
            workflow.task_tree.dump()
            raise

        # workflow.task_tree.dump()
        self.assert_(
            workflow.is_completed(),
            "complete_all() returned, but workflow is not complete\n" + workflow.task_tree.get_dump(),
        )

        # Make sure that there are no waiting tasks left in the tree.
        for thetask in Task.Iterator(workflow.task_tree, Task.READY):
            workflow.task_tree.dump()
            raise Exception("Task with state READY: %s" % thetask.name)

        # Check whether the correct route was taken.
        filename = xml_filename + ".path"
        if os.path.exists(filename):
            file = open(filename, "r")
            expected = file.read()
            file.close()
            taken_path = "\n".join(taken_path) + "\n"
            error = "%s:\n" % name
            error += "Expected:\n"
            error += "%s\n" % expected
            error += "but got:\n"
            error += "%s\n" % taken_path
            self.assert_(taken_path == expected, error)

        # Check attribute availibility.
        filename = xml_filename + ".data"
        if os.path.exists(filename):
            file = open(filename, "r")
            expected = file.read()
            file.close()
            result = workflow.get_attribute("data", "")
            error = "%s:\n" % name
            error += "Expected:\n"
            error += "%s\n" % expected
            error += "but got:\n"
            error += "%s\n" % result
            self.assert_(result == expected, error)
开发者ID:filipefigcorreia,项目名称:SpiffWorkflow,代码行数:55,代码来源:PatternTest.py

示例3: run_workflow

# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import complete_all [as 别名]
def run_workflow(test, wf_spec, expected_path, expected_data, workflow=None):
    # Execute all tasks within the Workflow.
    if workflow is None:
        taken_path = track_workflow(wf_spec)
        workflow   = Workflow(wf_spec)
    else:
        taken_path = track_workflow(workflow.spec)
        
    test.assert_(not workflow.is_completed(), 'Workflow is complete before start')
    try:
        # We allow the workflow to require a maximum of 5 seconds to
        # complete, to allow for testing long running tasks.
        for i in range(10):
            workflow.complete_all(False)
            if workflow.is_completed():
                break
            time.sleep(0.5)
    except:
        workflow.task_tree.dump()
        raise

    #workflow.task_tree.dump()
    test.assert_(workflow.is_completed(),
                 'complete_all() returned, but workflow is not complete\n'
               + workflow.task_tree.get_dump())

    # Make sure that there are no waiting tasks left in the tree.
    for thetask in Task.Iterator(workflow.task_tree, Task.READY):
        workflow.task_tree.dump()
        raise Exception('Task with state READY: %s' % thetask.name)

    # Check whether the correct route was taken.
    if expected_path is not None:
        taken_path = '\n'.join(taken_path) + '\n'
        error      = 'Expected:\n'
        error     += '%s\n'        % expected_path
        error     += 'but got:\n'
        error     += '%s\n'        % taken_path
        test.assert_(taken_path == expected_path, error)

    # Check data availibility.
    if expected_data is not None:
        result   = workflow.get_data('data', '')
        error    = 'Expected:\n'
        error   += '%s\n'        % expected_data
        error   += 'but got:\n'
        error   += '%s\n'        % result
        test.assert_(result == expected_data, error)

    return workflow
开发者ID:0-T-0,项目名称:SpiffWorkflow,代码行数:52,代码来源:util.py

示例4: _runWorkflow

# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import complete_all [as 别名]
    def _runWorkflow(self, wf_spec):
        taken_path = {'reached':   [],
                      'completed': []}
        for name, task in wf_spec.task_specs.iteritems():
            task.reached_event.connect(on_reached_cb, taken_path['reached'])
            task.completed_event.connect(on_complete_cb, taken_path['completed'])

        # Execute all tasks within the Workflow.
        workflow = Workflow(wf_spec)
        self.assert_(not workflow.is_completed(), 'Workflow complete before start')
        try:
            workflow.complete_all()
        except:
            workflow.dump()
            raise

        self.assert_(workflow.is_completed(),
                     'complete_all() returned, but workflow is not complete\n'
                   + workflow.task_tree.get_dump())
        #workflow.task_tree.dump()

        assert_same_path(self, self.expected_path, taken_path['completed'])
开发者ID:filipefigcorreia,项目名称:SpiffWorkflow,代码行数:24,代码来源:WorkflowTest.py

示例5: test_Merge_data_merging

# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import complete_all [as 别名]
    def test_Merge_data_merging(self):
        """Test that Merge task actually merges data"""
        wf_spec = WorkflowSpec()
        first = Simple(wf_spec, 'first')
        second = Simple(wf_spec, 'second')
        third = Simple(wf_spec, 'third')
        bump = Simple(wf_spec, 'bump')
        fourth = Simple(wf_spec, 'fourth')
        merge1 = Merge(wf_spec, 'merge 1')
        simple1 = Simple(wf_spec, 'simple 1')
        merge2 = Merge(wf_spec, 'merge 2')
        simple2 = Simple(wf_spec, 'simple 2')
        unmerged = Simple(wf_spec, 'unmerged')

        wf_spec.start.connect(first)
        wf_spec.start.connect(second)
        wf_spec.start.connect(third)
        wf_spec.start.connect(bump)
        bump.connect(fourth)  # Test join at different depths in tree

        first.connect(merge1)
        second.connect(merge1)
        second.connect(unmerged)

        first.connect(merge2)
        second.connect(merge2)
        third.connect(merge2)
        fourth.connect(merge2)

        merge1.connect(simple1)
        merge2.connect(simple2)

        workflow = Workflow(wf_spec)
        workflow.task_tree.set_attribute(everywhere=1)
        for task in workflow.get_tasks():
            task.set_attribute(**{'name': task.get_name(), task.get_name(): 1})
        workflow.complete_all()
        self.assertTrue(workflow.is_completed())
        found = {}
        for task in workflow.get_tasks():
            if task.task_spec is simple1:
                self.assertIn('first', task.attributes)
                self.assertIn('second', task.attributes)
                self.assertDictEqual(task.attributes, {'Start': 1,
                        'merge 1': 1, 'name': 'Start', 'simple 1': 1,
                        'second': 1, 'first': 1})
                found['simple1'] = task
            if task.task_spec is simple2:
                self.assertIn('first', task.attributes)
                self.assertIn('second', task.attributes)
                self.assertIn('third', task.attributes)
                self.assertIn('fourth', task.attributes)
                self.assertDictEqual(task.attributes, {'merge 2': 1,
                        'simple 2': 1, 'name': 'Start', 'third': 1, 'bump': 1,
                        'Start': 1, 'second': 1, 'first': 1, 'fourth': 1})
                found['simple2'] = task
            if task.task_spec is unmerged:
                self.assertDictEqual(task.attributes, {'Start': 1,
                        'second': 1, 'name': 'Start', 'unmerged': 1})
                found['unmerged'] = task
        self.assertIn('simple1', found)
        self.assertIn('simple2', found)
        self.assertIn('unmerged', found)
开发者ID:ccobbster,项目名称:SpiffWorkflow,代码行数:65,代码来源:JoinTest.py

示例6: open

# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import complete_all [as 别名]
import json
from SpiffWorkflow import Workflow
from SpiffWorkflow.specs import WorkflowSpec
from SpiffWorkflow.serializer.json import JSONSerializer

# Load from JSON
with open('nuclear.json') as fp:
    workflow_json = fp.read()
serializer = JSONSerializer()
spec = WorkflowSpec.deserialize(serializer, workflow_json)

# Alternatively, create an instance of the Python based specification.
#from nuclear import NuclearStrikeWorkflowSpec
#spec = NuclearStrikeWorkflowSpec()

# Create the workflow.
workflow = Workflow(spec)

# Execute until all tasks are done or require manual intervention.
# For the sake of this tutorial, we ignore the "manual" flag on the
# tasks. In practice, you probably don't want to do that.
workflow.complete_all(halt_on_manual=False)

# Alternatively, this is what a UI would do for a manual task.
#workflow.complete_task_from_id(...)
开发者ID:knipknap,项目名称:SpiffWorkflow,代码行数:27,代码来源:start.py


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