本文整理汇总了Java中org.xdi.exception.PythonException类的典型用法代码示例。如果您正苦于以下问题:Java PythonException类的具体用法?Java PythonException怎么用?Java PythonException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PythonException类属于org.xdi.exception包,在下文中一共展示了PythonException类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createExternalType
import org.xdi.exception.PythonException; //导入依赖的package包/类
private BaseExternalType createExternalType(CustomScript customScript, Map<String, SimpleCustomProperty> configurationAttributes) {
String customScriptInum = customScript.getInum();
BaseExternalType externalType;
try {
externalType = createExternalTypeFromStringWithPythonException(customScript, configurationAttributes);
} catch (PythonException ex) {
log.error("Failed to prepare external type '{}'", ex, customScriptInum);
return null;
}
if (externalType == null) {
log.debug("Using default external type class");
externalType = customScript.getScriptType().getDefaultImplementation();
}
return externalType;
}
示例2: loadPythonScript
import org.xdi.exception.PythonException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> T loadPythonScript(String scriptPythonType, Class<T> scriptJavaType, PyObject[] constructorArgs, PythonInterpreter interpreter)
throws PythonException {
PyObject scriptPythonTypeObject = interpreter.get(scriptPythonType);
if (scriptPythonTypeObject == null) {
return null;
}
PyObject scriptPythonTypeClass;
try {
scriptPythonTypeClass = scriptPythonTypeObject.__call__(constructorArgs);
} catch (Exception ex) {
log.error("Failed to initialize python class", ex.getMessage());
throw new PythonException(String.format("Failed to initialize python class '%s'", scriptPythonType), ex);
}
Object scriptJavaClass = scriptPythonTypeClass.__tojava__(scriptJavaType);
if (!ReflectHelper.assignableFrom(scriptJavaClass.getClass(), scriptJavaType)) {
return null;
}
return (T) scriptJavaClass;
}
示例3: createExternalTypeFromStringWithPythonException
import org.xdi.exception.PythonException; //导入依赖的package包/类
public BaseExternalType createExternalTypeFromStringWithPythonException(CustomScript customScript, Map<String, SimpleCustomProperty> configurationAttributes) throws PythonException {
String script = customScript.getScript();
if (script == null) {
return null;
}
CustomScriptType customScriptType = customScript.getScriptType();
BaseExternalType externalType = null;
InputStream bis = null;
try {
bis = new ByteArrayInputStream(script.getBytes("UTF-8"));
externalType = pythonService.loadPythonScript(bis, customScriptType.getPythonClass(),
customScriptType.getCustomScriptType(), new PyObject[] { new PyLong(System.currentTimeMillis()) });
} catch (UnsupportedEncodingException e) {
log.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(bis);
}
if (externalType == null) {
return null;
}
boolean initialized = false;
try {
initialized = externalType.init(configurationAttributes);
} catch (Exception ex) {
log.error("Failed to initialize custom script: '{}'", ex, customScript.getName());
}
if (initialized) {
return externalType;
}
return null;
}