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)
    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)
    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'])
Exemplo n.º 4
0
    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'])
Exemplo n.º 5
0
# 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.

for i in range(20):
            print(i)
            workflow.complete_all(False)
            if workflow.is_completed():
                break
            time.sleep(0.5)


#workflow.complete_all(halt_on_manual=False)
#workflow.complete_next()
#tasks = workflow.get_tasks(Task.WAITING)
#for t in tasks:
#    print(t.get_name())
#    t.complete()
#time.sleep(10)
# 类似get_dump(返回当前内部任务树的完整转储以进行调试),但是将输出打印到终端,而不是返回输出
workflow.dump()
# get_tasks_from_spec_name:返回其规范具有给定名称的所有任务。
# get_data:返回具有给定名称的数据字段的值,如果数据字段不存在,则返回给定的默认值。
print(workflow.get_tasks_from_spec_name('synch_1')[0].get_data('Result'))
print(workflow.get_tasks_from_spec_name('synch_1')[1].get_data('Result'))
print(workflow.get_tasks_from_spec_name('multi_choice_1')[0].get_data('result'))
print(workflow.get_tasks_from_spec_name('End')[0].get_data('Result'))

print(workflow.get_tasks_from_spec_name('Ping')[0].get_data('result'))
# print(workflow.get_tasks_from_spec_name('Ping')[0].results)