Posted by
Aryeh Weiss on
Apr 24, 2014; 8:33am
URL: http://imagej.273.s1.nabble.com/python-scripting-question-tp5007412.html
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