From: Frank C. <fc...@pu...> - 2002-04-01 07:47:34
|
I am embedding Jython 2.1 into TestMaker - a utility for developing intelligent test agents to test Web services for functionality and scalability. TestMaker is a Java application based on NetBeans. My code instantiates the PythonInterpreter object and then executes a script. I found that sys.path is not net - or set to . - and want to append the path to the jython/lib directory so that users will have access to other modules, including random. Everything I have tried has failed - sys.path remians simply . What is the final word on configuring embedded jython to recoganize the sys.path to find external modules? -Frank Adam Krieg <ak...@ma...>: I struggled with the same issue this week. The stuff in the FAQ documentation didn't work the first time I did it. Anyway, I played with a bit to get it to work. My Lib directory (where the modules are) are in ./Lib in this example. If this doesn't work, you can always uncommment out the last 2 lines, which is another way of doing the same thing. PythonInterpreter interpreter = new PythonInterpreter(); String libDir="."+File.separator+"Lib"; Properties props = new Properties(); props.setProperty("sys.path", libDir); PythonInterpreter.initialize(System.getProperties(), props, new String[] {""}); // interpreter.exec("import sys"); // interpreter.exec("sys.path.append('.\\Lib')"); -- Frank Cohen, CEO, PushToTest, www.pushtotest.com, phone: 408 374 7426 Come to PushToTest for free open-source Active Security solutions that test, monitor and automate Web Service systems for functionality, scalability and performance. |