|
From: Frank C. <fc...@pu...> - 2002-01-21 21:44:37
|
Hi all: Thanks so much for all the hard work being done on Jython. I think Jython is a terrific project. I am embedding Jython into the next version of PushToTest Load - a framework for writing intelligent test agents to test Web services for scalability and performance. Details are at: http://www.pushtotest.com/ptt/wiki/LoadPreview Load will be implemented as a NetBeans module (http://www.netbeans.org.) The module instantiates an instance of Jython and passes it a script to run. Here's the code I'm using: PythonInterpreter interp = new PythonInterpreter(); try { interp.execfile( FileUtil.toFile(theScriptFile).getPath() ); } catch ( PyException e ) { System.out.println( "1=" + e.fillInStackTrace() ); System.out.println( "2=" + e.getLocalizedMessage() ); System.out.println( "3=" + e.getMessage() ); System.out.println( "e.traceback.tb_lineno = " + e.traceback.tb_lineno ); System.out.println( "e.traceback.tb_frame = " + e.traceback.tb_frame ); System.out.println( "e.traceback.tb_next = " + e.traceback.tb_next ); } This works well except for importing Jython libraries. When I run this script: import random print "Hi its me here at test.py" i=10 print i print random.random() I get this exception: Traceback (innermost last): File "<string>", line 1, in ? ImportError: no module named random at org.python.core.Py.ImportError(Py.java:180) at org.python.core.imp.load(imp.java:368) at org.python.core.imp.load(imp.java:376) at org.python.core.imp.importName(imp.java:447) at org.python.core.imp.importName(imp.java:509) at org.python.core.ImportFunction.load(__builtin__.java:967) at org.python.core.ImportFunction.__call__(__builtin__.java:961) at org.python.core.PyObject.__call__(PyObject.java:250) at org.python.core.__builtin__.__import__(__builtin__.java:921) at org.python.core.imp.importOne(imp.java:518) at org.python.pycode._pyx8.f$0(<string>) at org.python.pycode._pyx8.call_function(<string>) at org.python.core.PyTableCode.call(PyTableCode.java:155) at org.python.core.Py.runCode(Py.java:1055) at org.python.core.Py.exec(Py.java:1076) at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:135) at org.netbeans.modules.scripting.JPythonScriptType.exec(JPythonScriptType.java :99) at org.netbeans.modules.scripting.AbstractScriptType.exec(AbstractScriptType.ja va:140) at org.openide.execution.ScriptType.exec(ScriptType.java:80) at org.netbeans.modules.scripting.ScriptSupport$1.run(ScriptSupport.java:72) at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:118) The classpath is pointed to the jython.jar file. Does anyone have a direction to point me in to figure this out? -Frank |