From: Ihab A.B. A. <ih...@ah...> - 2001-10-22 17:18:38
|
Hi all, Thanks Robert Bill & Jim Adrig for the tips.... > Yes, os requires the javaos module, and you get the ImportError when that > module cannot be Located. Fix= make sure module is found. I've been trying, in every manner possible! Here's my code -- rootPath = servletContext.getRealPath("/"); if (!rootPath.endsWith(File.separator)) rootPath += File.separator; Properties p = getInitParametersAsProperties(); p.put( "python.cachedir", servletContext.getAttribute("javax.servlet.context.tempdir").toString()); PythonInterpreter.initialize(System.getProperties(), p, new String[0]); PySystemState pySys = Py.getSystemState(); pySys.add_classdir(rootPath + "WEB-INF" + File.separator + "classes"); pySys.add_extdir(rootPath + "WEB-INF" + File.separator + "lib"); pySys.path.append(new PyString(servletContext.getAttribute("python.home") + File.separator + "Lib")); pySys.path.append(new PyString(rootPath + "WEB-INF" + File.separator + "py")); pythonInterpreter = new PythonInterpreter(null, pySys); I think, based on looking at PyServlet.java, that this should get all my bases covered. However, I still get -- import os dir(os) Traceback (innermost last): File "", line 10, in ? ImportError: no module named javaos import os print os.listdir('/home/ihab') Traceback (innermost last): File "", line 2, in ? AttributeError: class 'org.python.modules.os' has no attribute 'listdir' This is all very confusing. Any help appreciated from anyone. Peace, Ihab -- Ihab A.B. Awad <ih...@ah...> Center for Computational Genomics and Bioinformatics, University of Minnesota. http://www.cbc.umn.edu/~ihab/ |