本文整理汇总了Python中EDJob.EDJob.synchronize方法的典型用法代码示例。如果您正苦于以下问题:Python EDJob.synchronize方法的具体用法?Python EDJob.synchronize怎么用?Python EDJob.synchronize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EDJob.EDJob
的用法示例。
在下文中一共展示了EDJob.synchronize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runEdnaPlugin
# 需要导入模块: from EDJob import EDJob [as 别名]
# 或者: from EDJob.EDJob import synchronize [as 别名]
def runEdnaPlugin(execPath, pluginName, isDebug, xml, additionalPaths=None):
'''
execPath - path to run plugin in
pluginName - plugin name
isDebug - True if should run edna in debug mode
xml - xml input to edna
additionalPaths - list of other python path locations
You must set EDNA_HOME to use this method
This method blocks until the EDJob has reached a final status
'''
if (not 'EDNA_HOME' in os.environ):
raise Exception("Cannot locate EDNA_HOME. Please set before running Edna plugins.")
if (not 'EDNA_SITE' in os.environ):
raise Exception(" Please set EDNA_SITE before running Edna plugins.")
'''
Add edna to path
'''
ednaKernelPath = os.environ['EDNA_HOME']+"/kernel/src"
sys.path.insert(0, ednaKernelPath)
'''
If there are any additional paths such as fabio, add these
'''
if (not additionalPaths is None and len(additionalPaths)>0):
for path in additionalPaths:
sys.path.append(path)
os.chdir(execPath)
from EDVerbose import EDVerbose
if (isDebug):
EDVerbose.setVerboseDebugOn()
else:
EDVerbose.setVerboseOn()
EDVerbose.setVerboseDebugOff()
from EDJob import EDJob
EDVerbose.setLogFileName(execPath+"/"+pluginName+".log")
edJob = EDJob(pluginName)
edJob.setDataInput(xml)
edJob.execute()
edJob.synchronize() # In theory should mean that the following loop is not needed
# Unhelpful way of waiting for EDJob to be finished
# TODO Fix this in EDJob some time
while(True):
status = edJob.getStatus()
if (status is None):
time.sleep(0.2) # 200 ms
continue
if ("failure" == status):
raise Exception("EDJob failed! ")
if ("success" == status):
break
ret = edJob.getDataOutput()
return str(ret)