当前位置: 首页>>代码示例>>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;未经允许,请勿转载。