當前位置: 首頁>>代碼示例>>Java>>正文


Java PythonInterpreter.cleanup方法代碼示例

本文整理匯總了Java中org.python.util.PythonInterpreter.cleanup方法的典型用法代碼示例。如果您正苦於以下問題:Java PythonInterpreter.cleanup方法的具體用法?Java PythonInterpreter.cleanup怎麽用?Java PythonInterpreter.cleanup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.python.util.PythonInterpreter的用法示例。


在下文中一共展示了PythonInterpreter.cleanup方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: CreateFromPython

import org.python.util.PythonInterpreter; //導入方法依賴的package包/類
public void CreateFromPython()
	{
		PythonInterpreter interpreter = new PythonInterpreter(null, new PySystemState());

		PySystemState sys = Py.getSystemState();

		sys.path.append(new PyString(context.settings.GetModelPath()));

		if(context.settings.GetSysPath() != null)
			sys.path.append(new PyString(context.settings.GetSysPath()));

		/*
// some magic to pass context to all python modules
		interpreter.set("context", context);
		interpreter.set("model_service", model_service);
		interpreter.exec("import __builtin__");
		interpreter.exec("__builtin__.context = context");
		interpreter.exec("__builtin__.model_service = model_service");*/

		interpreter.execfile(context.settings.GetModelPath() + '/' + context.settings.GetModelMain());

		interpreter.cleanup();

		UpdateDefinedSensors();
	}
 
開發者ID:srcc-msu,項目名稱:octotron_core,代碼行數:26,代碼來源:ExecutionService.java

示例2: runCxxTestGen

import org.python.util.PythonInterpreter; //導入方法依賴的package包/類
private void runCxxTestGen( String testTarget, List<String> arguments ) throws MojoExecutionException
{
    final String cxxTestGenArgVar = "cxxTestGenArgs";
    
    String cxxTestGenPath = cxxTest.getCxxTestHome().getAbsolutePath();
    PyList cxxTestGenArgs = new PyList( arguments );
    cxxTestGenArgs.add( 0, cxxTestGenPath );
    
    getLog().info( "Executing test runner generation for target " + testTarget + "." );
    getLog().debug( "Executing Python script " + cxxTestGenPath + " with arguments=" + cxxTestGenArgs );

    PythonInterpreter pythonInterpreter = new PythonInterpreter();
    pythonInterpreter.exec( "import cxxtest" );
    resetCxxTestSuites( pythonInterpreter );
    
    pythonInterpreter.set( cxxTestGenArgVar, cxxTestGenArgs );
    pythonInterpreter.exec( "cxxtest.main(" + cxxTestGenArgVar + ")" );  
    pythonInterpreter.cleanup();
    
    getLog().info( "Test runner generation for target " + testTarget + " succeeded." );
}
 
開發者ID:andi12,項目名稱:msbuild-maven-plugin,代碼行數:22,代碼來源:CxxTestGenMojo.java

示例3: loadFromFile

import org.python.util.PythonInterpreter; //導入方法依賴的package包/類
/**
 * Loads a module from a Python file that contains a class with the <b>SAME</b> name as the file.
 * The class must extend {@link ExternalModule}.
 *
 * @param f the file to load the {@link org.freecode.irc.votebot.api.ExternalModule} from
 * @return the {@link ExternalModule} loaded, or <tt>null</tt>
 * @throws IOException     if the file was not found
 * @throws ScriptException if the script failed to load
 */
public ExternalModule loadFromFile(final File f) throws IOException, ScriptException {
    if (f == null || !f.exists()) {
        throw new IOException("Invalid file");
    }
    if (f.getName().endsWith(".py")) {
        PythonInterpreter interpreter = new PythonInterpreter();
        String clzName = f.getName().replace(".py", "");
        interpreter.exec(String.format("from %s import %s", clzName, clzName));
        PyObject pyClass = interpreter.get(clzName);
        PyObject buildObject = pyClass.__call__();
        ExternalModule ext = (ExternalModule) buildObject.__tojava__(ExternalModule.class);
        ext.setFvb(fvb);
        ext.setExtName(clzName);
        interpreter.cleanup();
        return ext;
    }
    return null;

}
 
開發者ID:freecode,項目名稱:FreeVoteBot,代碼行數:29,代碼來源:ScriptModuleLoader.java

示例4: recompile

import org.python.util.PythonInterpreter; //導入方法依賴的package包/類
@Override
public boolean recompile(boolean reload) {
	
	if(reload){
		this.setScript(this.extractFile());
	}
	
	PythonInterpreter python = new PythonInterpreter();
	this.setCompiled(python.compile(this.getScript()));
	python.cleanup();
	
	return true;
}
 
開發者ID:mwambler,項目名稱:xockets.io,代碼行數:14,代碼來源:PythonScript.java

示例5: buildPythonInterpreter

import org.python.util.PythonInterpreter; //導入方法依賴的package包/類
public static PythonInterpreter buildPythonInterpreter(PyObject dist, boolean cleanup) {
	PythonInterpreter pyInterpreter = PythonInterpreter.threadLocalStateInterpreter(dist);
	if (cleanup) {
		pyInterpreter.cleanup();
	}
	return pyInterpreter;
}
 
開發者ID:billchen198318,項目名稱:bamboobsc,代碼行數:8,代碼來源:ScriptExpressionUtils.java

示例6: getMethod

import org.python.util.PythonInterpreter; //導入方法依賴的package包/類
private static PyObject getMethod(String path, String module, String method) {	// Ziggy: This could probably be moved to callScript()
	PythonInterpreter python = new PythonInterpreter();							// since it's not used elsewhere.
	python.cleanup();
	python.execfile(path + module + ".py");
	
	return python.get(method);
}
 
開發者ID:swgopenge,項目名稱:openge,代碼行數:8,代碼來源:ScriptingManager.java

示例7: callScript

import org.python.util.PythonInterpreter; //導入方法依賴的package包/類
public void callScript(String path, String module, String method) {
	PythonInterpreter interpreter = new PythonInterpreter();
	interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method);	
	PyObject func = interpreter.get(method);
	func.__call__(Py.java2py(core));
	interpreter.cleanup();
}
 
開發者ID:uberamd,項目名稱:NGECore2,代碼行數:8,代碼來源:ScriptService.java


注:本文中的org.python.util.PythonInterpreter.cleanup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。