本文整理汇总了Python中SpiffWorkflow.Workflow.get_tasks方法的典型用法代码示例。如果您正苦于以下问题:Python Workflow.get_tasks方法的具体用法?Python Workflow.get_tasks怎么用?Python Workflow.get_tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpiffWorkflow.Workflow
的用法示例。
在下文中一共展示了Workflow.get_tasks方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _advance_to_a1
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import get_tasks [as 别名]
def _advance_to_a1(self, wf_spec):
workflow = Workflow(wf_spec)
tasks = workflow.get_tasks(Task.READY)
task_start = tasks[0]
workflow.complete_task_from_id(task_start.id)
tasks = workflow.get_tasks(Task.READY)
multichoice = tasks[0]
workflow.complete_task_from_id(multichoice.id)
tasks = workflow.get_tasks(Task.READY)
task_a1 = tasks[0]
workflow.complete_task_from_id(task_a1.id)
return workflow
示例2: deserialize_workflow
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import get_tasks [as 别名]
def deserialize_workflow(self, s_state, **kwargs):
wf_spec = self.deserialize_workflow_spec(s_state['wf_spec'], **kwargs)
workflow = Workflow(wf_spec)
# data
workflow.data = s_state['data']
# last_task
workflow.last_task = s_state['last_task']
# outer_workflow
#workflow.outer_workflow = find_workflow_by_id(remap_workflow_id(s_state['outer_workflow']))
# success
workflow.success = s_state['success']
# workflow
workflow.spec = wf_spec
# task_tree
workflow.task_tree = self._deserialize_task(workflow, s_state['task_tree'])
# Re-connect parents
for task in workflow.get_tasks():
task.parent = workflow.get_task(task.parent)
return workflow
示例3: start_workflow
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import get_tasks [as 别名]
def start_workflow(workflow_name):
""" start workflow for graduation project """
# create workflow instance
workflow = Workflow(workflow_specs[workflow_name])
# complete start task
start_task = workflow.get_tasks(state=Task.READY)[0]
workflow.complete_task_from_id(start_task.id)
# save username in workflow
workflow.data["student"] = g.user.username
# save workflow instance to database
save_workflow_instance(workflow, g.user.id)
return redirect(url_for('.user_page', username=g.user.username))
示例4: testBeginWorkflowStepByStep
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import get_tasks [as 别名]
def testBeginWorkflowStepByStep(self):
"""
Simulates interactive calls, as would be issued by a user.
"""
xml_file = os.path.join(data_dir, 'spiff', 'workflow1.xml')
xml = open(xml_file).read()
wf_spec = WorkflowSpec.deserialize(XmlSerializer(), xml)
workflow = Workflow(wf_spec)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 1)
self.assertEqual(tasks[0].task_spec.name, 'Start')
workflow.complete_task_from_id(tasks[0].id)
self.assertEqual(tasks[0].state, Task.COMPLETED)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 2)
task_a1 = tasks[0]
task_b1 = tasks[1]
self.assertEqual(task_a1.task_spec.__class__, Simple)
self.assertEqual(task_a1.task_spec.name, 'task_a1')
self.assertEqual(task_b1.task_spec.__class__, Simple)
self.assertEqual(task_b1.task_spec.name, 'task_b1')
workflow.complete_task_from_id(task_a1.id)
self.assertEqual(task_a1.state, Task.COMPLETED)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 2)
self.assertTrue(task_b1 in tasks)
task_a2 = tasks[0]
self.assertEqual(task_a2.task_spec.__class__, Simple)
self.assertEqual(task_a2.task_spec.name, 'task_a2')
workflow.complete_task_from_id(task_a2.id)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 1)
self.assertTrue(task_b1 in tasks)
workflow.complete_task_from_id(task_b1.id)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 1)
workflow.complete_task_from_id(tasks[0].id)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 1)
self.assertEqual(tasks[0].task_spec.name, 'synch_1')
示例5: testBeginWorkflowStepByStep
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import get_tasks [as 别名]
def testBeginWorkflowStepByStep(self):
"""
Simulates interactive calls, as would be issued by a user.
"""
wf_spec = self._createWorkflowSpec()
workflow = Workflow(wf_spec)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 1)
self.assertEqual(tasks[0].task_spec.name, 'Start')
workflow.complete_task_from_id(tasks[0].id)
self.assertEqual(tasks[0].state, Task.COMPLETED)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 2)
task_a1 = tasks[0]
task_b1 = tasks[1]
self.assertEqual(task_a1.task_spec.__class__, Simple)
self.assertEqual(task_a1.task_spec.name, 'task_a1')
self.assertEqual(task_b1.task_spec.__class__, Simple)
self.assertEqual(task_b1.task_spec.name, 'task_b1')
workflow.complete_task_from_id(task_a1.id)
self.assertEqual(task_a1.state, Task.COMPLETED)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 2)
self.assertTrue(task_b1 in tasks)
task_a2 = tasks[0]
self.assertEqual(task_a2.task_spec.__class__, Simple)
self.assertEqual(task_a2.task_spec.name, 'task_a2')
workflow.complete_task_from_id(task_a2.id)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 1)
self.assertTrue(task_b1 in tasks)
workflow.complete_task_from_id(task_b1.id)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 1)
workflow.complete_task_from_id(tasks[0].id)
tasks = workflow.get_tasks(Task.READY)
self.assertEqual(len(tasks), 1)
self.assertEqual(tasks[0].task_spec.name, 'synch_1')
示例6: test_Merge_data_merging
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import get_tasks [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)