当前位置: 首页>>代码示例>>Java>>正文


Java Py.setSystemState方法代码示例

本文整理汇总了Java中org.python.core.Py.setSystemState方法的典型用法代码示例。如果您正苦于以下问题:Java Py.setSystemState方法的具体用法?Java Py.setSystemState怎么用?Java Py.setSystemState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.python.core.Py的用法示例。


在下文中一共展示了Py.setSystemState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupSystemState

import org.python.core.Py; //导入方法依赖的package包/类
/**
 * Call to ensure that an interpreter is set up and configured and
 * able to load the relevant bundles.
 */
public static synchronized void setupSystemState(String... bundleNames) {

	ClassLoader loader=null;
	if (configuredState==null) { // Relies on setupSystemState() being called early in the server startup.
		loader = createJythonClassLoader(PySystemState.class.getClassLoader());
		initializePythonPath(loader);
	}

PySystemState state = Py.getSystemState();
if (state==configuredState) return;

if (loader==null) {
	// Then someone else has changed the PySystemState
	// They will not have added our
		loader = createJythonClassLoader(state.getClassLoader());   // Don't clobber their working.
}
	state.setClassLoader(loader);

setJythonPaths(state);       // Tries to ensure that enough of jython is on the path
setSpgGeneratorPaths(state, bundleNames); // Adds the scripts directory from points
	Py.setSystemState(state);

	configuredState = state;
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:29,代码来源:JythonInterpreterManager.java

示例2: enter

import org.python.core.Py; //导入方法依赖的package包/类
@Override
public Object enter( String entryPointName, Executable executable, ExecutionContext executionContext, Object... arguments ) throws NoSuchMethodException, ParsingException, ExecutionException
{
	entryPointName = toPythonStyle( entryPointName );
	PythonInterpreter pythonInterpreter = (PythonInterpreter) executionContext.getAttributes().get( JYTHON_INTERPRETER );
	Py.setSystemState( pythonInterpreter.getSystemState() );
	PyObject method = pythonInterpreter.get( entryPointName );
	if( method == null )
		throw new NoSuchMethodException( entryPointName );
	try
	{
		PyObject[] pythonArguments = Py.javas2pys( arguments );
		PyObject r = method.__call__( pythonArguments );
		return r.__tojava__( Object.class );
	}
	catch( Exception x )
	{
		throw JythonAdapter.createExecutionException( executable.getDocumentName(), 0, x );
	}
	finally
	{
		flush( pythonInterpreter, executionContext );
	}
}
 
开发者ID:tliron,项目名称:scripturian,代码行数:25,代码来源:JythonAdapter.java

示例3: setPythonPath

import org.python.core.Py; //导入方法依赖的package包/类
private void setPythonPath(Engine engine) {
    if (engine != null) {
        String pythonPath = engine.getConfigurationManager().getProperty(PROP_PYTHON_PATH);
        if (pythonPath != null) {
            PySystemState engineSys = new PySystemState();
            List<String> paths = Arrays.asList(StringUtils.split(pythonPath, PROP_PATH_SEPARATOR));
            Collections.reverse(paths);
            for (String pathElement : paths) {
                engineSys.path.add(0, Py.newString(pathElement));
            }

            Py.setSystemState(engineSys);
        }
    }
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:16,代码来源:JythonKnowledgeBaseInterpreter.java


注:本文中的org.python.core.Py.setSystemState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。