From: Sébastien D. <se...@de...> - 2011-05-10 09:40:20
|
Hi Guys, I am currently building a forge that propose Wiki functionnality persisted in DVCS (GIT, Mercurial) and use RestructuredText as main wiki language. In order to acheive this, we have bundled docutils within jython-2.5.2.jar, and called it from our Java code. It works fine, even if startup type before the first call seems to me quite long (10 seconds). The main issue is that it works when we run the rst2html the first time, but next calls return empty content. I suspect that JarRunner, originally made to be called from a unique main method, is the root of our issue. Our code is the following, and run the __run__.py built from rst2html.py : public String generate(File source) throws IOException { String[] commandLine= new String[5]; commandLine[0] = source.getAbsolutePath(); commandLine[1] = "--stylesheet"; commandLine[2] = css.getAbsolutePath(); commandLine[3] = "--template"; commandLine[4] = template.getAbsolutePath(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); System.setOut(ps); JarRunner.run(commandLine); ps.flush(); baos.flush(); return baos.toString(); } What I plan to do, but not really know how : - Intialize Python state one time, at the creation of my Rst2Html.jar class - Use directly PythonInterpreter to run the content of rst2html.py Does anybody has already used Jython in such server context to run command line multiple times ? How could I run PythonInterpreter to run rst2html.py ? I sthere a more appropriate way to do this ? Thanks in advance, Sébastien |