Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Using JYTHON inside ANT : access os module -> "ImportError: no module named javaos" (http://www.velocityreviews.com/forums/t336566-using-jython-inside-ant-access-os-module-importerror-no-module-named-javaos.html)

eric_bellard 10-05-2004 03:38 PM

Using JYTHON inside ANT : access os module -> "ImportError: no module named javaos"
 
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

CarlosRivera 10-07-2004 05:41 AM

Re: Using JYTHON inside ANT : access os module -> "ImportError: nomodule named javaos"
 
I ran into that one as well. I think that you have to have the PYTHON
path or classpath properly setup to reference them. I did not really
need anything from python, so I just used java routines for everything
as I was generating a manifest file.

Tip: Due to the forced indent from python, I moved the script to a
separate file. This way the code can look like a normal jython/python
script.

eric_bellard wrote:
> 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



All times are GMT. The time now is 10:17 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.