1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
class PythonScriptInterpreter {
private InteractiveInterpreter interp = new InteractiveInterpreter();
public PythonScriptInterpreter()
{
interp = new InteractiveInterpreter();
Properties props = new Properties();
//Le chemin des librairies python
props.setProperty( "python24.path", "lib/Lib" );
PythonInterpreter.initialize( System.getProperties( ), props, new String[]{""});
}
public void executeScript(String fileName)
{
try
{
interp.cleanup();
interp.execfile( fileName );
}
catch(PyException pyEx)
{
System.out.println(pyEx.toString());
}
}
public void interp(String s)
{
PythonScriptInterpreter interpreter = new PythonScriptInterpreter();
interpreter.executeScript(s);
}
} |
Partager