python scripting question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

python scripting question

Aryeh Weiss
I have the following snippet in my code, designed to create an output
directory if it does not already exist:

91 outDir = os.path.join(inputDir,"zPlots/")
92 print outDir
93 if not os.path.exists(outDir):
94     os.makedirs(outDir)


If the directory exists, this runs ok. If I skip line 93 and make the
directory withotu checking,

If the directory does not exist, it produces an error.

File "<iostream>", line 93, in <module>
File "/Applications/local/fiji/Fiji.app/jars/jython-2.7-bl.jar
/Lib/posixpath.py", line 171, in exists
File "/Applications/local/fiji/Fiji.app/jars/jython-2.7-bl.jar
/Lib/posixpath.py", line 171, in exists
java.lang.AbstractMethodError:
org.python.modules.posix.PythonPOSIXHandler.error(Ljnr/constants/platform/Errno;Ljava/lang/String;)V
     at jnr.posix.BaseNativePOSIX.stat(BaseNativePOSIX.java:309)

There is these a long list of at jnr.posix ... and org.posix.... etc ,
which I have not copied.
(BTW -- is there a way to copy the text from the error display of the
Fiji script editor?)

I also tried

outDir = inputDir + "zPlots/"

with the same problem.

I tried also to use try and except on this.
except AbstractMethodError seems to catch this.
I suppose I could catch any failure and assume that the directory
exists, but this does not seem the correct
way to do this.

Thanks in advance for any assistance on this.
--aryeh

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: python scripting question

Albert Cardona-2
2014-04-24 4:33 GMT-04:00 Aryeh Weiss <[hidden email]>:

> I have the following snippet in my code, designed to create an output
> directory if it does not already exist:
>
> 91 outDir = os.path.join(inputDir,"zPlots/")
> 92 print outDir
> 93 if not os.path.exists(outDir):
> 94     os.makedirs(outDir)
>
>
> If the directory exists, this runs ok. If I skip line 93 and make the
> directory withotu checking,
>
> If the directory does not exist, it produces an error.
>
> File "<iostream>", line 93, in <module>
> File "/Applications/local/fiji/Fiji.app/jars/jython-2.7-bl.jar
> /Lib/posixpath.py", line 171, in exists
> File "/Applications/local/fiji/Fiji.app/jars/jython-2.7-bl.jar
> /Lib/posixpath.py", line 171, in exists
> java.lang.AbstractMethodError: org.python.modules.posix.
> PythonPOSIXHandler.error(Ljnr/constants/platform/Errno;
> Ljava/lang/String;)V
>     at jnr.posix.BaseNativePOSIX.stat(BaseNativePOSIX.java:309)
>
> There is these a long list of at jnr.posix ... and org.posix.... etc ,
> which I have not copied.
> (BTW -- is there a way to copy the text from the error display of the Fiji
> script editor?)
>
> I also tried
>
> outDir = inputDir + "zPlots/"
>
> with the same problem.
>
> I tried also to use try and except on this.
> except AbstractMethodError seems to catch this.
> I suppose I could catch any failure and assume that the directory exists,
> but this does not seem the correct
> way to do this.
>
> Thanks in advance for any assistance on this.
> --aryeh
>



Aryeh,

you are using jython 2.7, which still in beta. The jython developers would
appreciate a minimal script to reproduce the problem in a bug report, here:

https://wiki.python.org/jython/ReportingBugs

Albert

--
http://albert.rierol.net
http://www.ini.uzh.ch/~acardona/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html