shutil.rmtree raises "OSError: [Errno 39] Directory not empty" exception

2009-07-10 Thread Maria Liukis

Hello,

Has anybody seen an exception "OSError: [Errno 39] Directory not  
empty" raised by shutil.rmtree? The code that raised an exception  
creates a lot of directories with files, and then removes them. I got  
an exception when one of such directories was removed. Here is the  
backtrace:


shutil.rmtree(filename)
  File "/usr/lib64/python2.5/shutil.py", line 178, in rmtree
onerror(os.rmdir, path, sys.exc_info())
  File "/usr/lib64/python2.5/shutil.py", line 176, in rmtree
os.rmdir(path)
OSError: [Errno 39] Directory not empty: /path/to/my/dir

According to the documentation, shutil.rmtree should not care about  
directory being not empty.


Thanks for the help,
Masha

liu...@usc.edu



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shutil.rmtree raises "OSError: [Errno 39] Directory not empty" exception

2009-07-10 Thread Maria Liukis
Thanks for pointing out the parameters for ignore_errors and an  
onerror callback function.


I have been running this code for more than an year, and this is the  
very first time I see the problem. We switched to the NFS mounted  
storage though, but there is nothing unusual logged by the system in  
the /var/log/messages.


I checked the permissions - the directory is still there and has  
exactly the same permissions as other successfully copied and removed  
directories (the very same process creates the directory and later  
removes it). The directory is empty though - so the process removed  
all the entries in it, then some kind of an error occured that  
triggered the exception.


There are lots of similar directories that the process creates and  
removes, but only one of them raised an exception.


Thanks,
Masha

liu...@usc.edu



On Jul 10, 2009, at 5:10 PM, Tim Chase wrote:


 shutil.rmtree(filename)
   File "/usr/lib64/python2.5/shutil.py", line 178, in rmtree
 onerror(os.rmdir, path, sys.exc_info())
   File "/usr/lib64/python2.5/shutil.py", line 176, in rmtree
 os.rmdir(path)
OSError: [Errno 39] Directory not empty: /path/to/my/dir
According to the documentation, shutil.rmtree should not care  
about  directory being not empty.


This sounds suspiciously like a permission issue.  rmtree()  
*should* walk the tree removing items *if it can*.  If a file can't  
be deleted, it treats it as an error.  rmtree() takes parameters  
for ignore_errors and an onerror callback function, so you can  
catch these error conditions.


-tkc




-- 
http://mail.python.org/mailman/listinfo/python-list


Any built-in function for smallest positive floating point number?

2009-08-11 Thread Maria Liukis

Hello everybody,

Is somebody aware of built-in Python's function that would return a  
value for smallest positive double precision floating point number  
(analogous to 'realmin' in Matlab). Python has built-in sys.maxint  
but I could not find anything for float.


Any help would be greatly appreciated.

Thanks,
Masha

liu...@usc.edu



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Any built-in function for smallest positive floating point number?

2009-08-11 Thread Maria Liukis

A bit more of googling gave me an answer:

>>> import numpy as np
>>> np.finfo(np.double).tiny
array(2.2250738585072014e-308)
>>>

Thanks,
Masha

liu...@usc.edu



On Aug 11, 2009, at 10:29 AM, Maria Liukis wrote:


Hello everybody,

Is somebody aware of built-in Python's function that would return a  
value for smallest positive double precision floating point number  
(analogous to 'realmin' in Matlab). Python has built-in sys.maxint  
but I could not find anything for float.


Any help would be greatly appreciated.

Thanks,
Masha

liu...@usc.edu



--
http://mail.python.org/mailman/listinfo/python-list


-- 
http://mail.python.org/mailman/listinfo/python-list