27.04.2011 17:18, Bojan RELJIC kirjoitti:
Hi all,

I use Jython 2.5.2's ScriptEngine, to execute python files with Java (1.6):

...
            ScriptEngineManager mgr = new ScriptEngineManager();
            pyEngine = mgr.getEngineByName("python");
            pyEngine.eval(script);
...

However, it fails to evaluate python files bigger then 100.000 characters, with IOException :

javax.script.ScriptException: java.io.IOException: java.io.IOException: Mark invalid
        at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:196)
        at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:75)
        at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
        at testjython.Main.run(Main.java:36)
        at testjython.Main.main(Main.java:56)
Caused by: java.io.IOException: Mark invalid

java.io.IOException: java.io.IOException: Mark invalid

        at org.python.core.PyException.fillInStackTrace(PyException.java:70)
        at java.lang.Throwable.<init>(Throwable.java:181)
        at java.lang.Exception.<init>(Exception.java:29)
        at java.lang.RuntimeException.<init>(RuntimeException.java:32)
        at org.python.core.PyException.<init>(PyException.java:46)
        at org.python.core.PyException.<init>(PyException.java:43)
        at org.python.core.Py.JavaError(Py.java:481)
        at org.python.core.ParserFacade.fixParseError(ParserFacade.java:104)
        at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:130)


Test ended.
        at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:259)
        at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:256)
        at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:250)
        at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:70)
        ... 4 more
Caused by: java.io.IOException: Mark invalid
        at java.io.BufferedReader.reset(BufferedReader.java:485)
        at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:127)
        ... 8 more

I found that this is hardcoded in org.python.core.ParserFacade.MARK_LIMIT constant.

So, the question is: Is there any way to execute python scripts from java ScriptEngine which are longer then 100K characters.

The reason why I execute this big files is because I don't know if it is possible to import other .py files in the main .py file which is executed by the ScriptEngine. So, I simply concatenate a few files, which finally easily reaches 100.000 characters.
Of course you can import other modules. Do you mean you never tried that approach?


Cheers,
Bojan


------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________ Jython-users mailing list Jython-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jython-users