當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。