本文整理汇总了Python中SpiffWorkflow.Workflow.get_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python Workflow.get_attribute方法的具体用法?Python Workflow.get_attribute怎么用?Python Workflow.get_attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpiffWorkflow.Workflow
的用法示例。
在下文中一共展示了Workflow.get_attribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runWorkflow
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import get_attribute [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)
示例2: run_workflow
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import get_attribute [as 别名]
def run_workflow(test, wf_spec, expected_path, expected_data, max_tries=1):
# Execute all tasks within the Workflow.
taken_path = track_workflow(wf_spec)
workflow = Workflow(wf_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()
complete = False
while max_tries > 0 and complete is False:
max_tries -= 1
complete = workflow.is_completed()
test.assert_(complete,
'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 attribute availibility.
if expected_data is not None:
result = workflow.get_attribute('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