Using JYTHON inside ANT : access os module -> "ImportError: no module named javaos"

eric_bellard eric_bellard_nospam at yahoo.com
Tue Oct 5 11:38:33 EDT 2004


Using JYTHO inside ANT : access os module

Hi,

I like to use JYTHON inside ANT task.

I'm using:
- WSAD 5.1.1
- jython.jar inside WTE5.1
- bsf.jar inside WTE5.1

I've referenced jython.jar and bsf.jar into the ant classpath
(Windows>Preferences>Ant>Runtime>Classpath)

Here's a working script:

<project name="helloWorld" default="jython-hello-world" basedir=".">

	<property name="test.path.dir" location="D:/tmp/jyton"/>
	<target name="jython-hello-world">
		<script language="jython"> 
			<![CDATA[
import sys


print 'Hello Jytho World'
path = project.getProperty("test.path.dir")
print path
			
			]]> 
		</script>		
	</target>
</project>


The problem is when I want to access to the ptyhon 'os' module.
The following target don't work:
	<target name="jython-hello-world2">
		<script language="jython"> 
			<![CDATA[
import sys, os


print 'Hello Jytho World'
path = project.getProperty("test.path.dir")
print path
os.listdir(path)			
			]]> 
		</script>		
	</target>


The returned error is:

jython-hello-world:
      [script] Hello Jytho World
      [script] D:\tmp\jyton
      [script] BUILD FAILED:
file:D:/cc_views/dinb_comp_java_jraf_v2_0_act_E391485/dinb_comp_java_jraf/livraison/jython/build.xml:63:
Traceback (innermost last):
  File "<string>", line 8, in ?
ImportError: no module named javaos


Does someone has any clue?

Thanks by advance.

Eric



More information about the Python-list mailing list