[Python-Dev] urllib.urlretrieve() and handling 550 errors when reading from FTP

Guido van Rossum guido at python.org
Mon Jul 12 05:55:39 CEST 2004


> > Why should I have to use a trailing backslash to get a directory
> > listing?  That's not in the FTP standard and probably won't work
> > everywhere.
> 
> It's the way the code is written for the FTP wrapper in urllib; has 
> nothing to do with ftp.python.org or FTP.  Basically the code checks to 
> see if there is a trailing slash.  If it does it assumes it is a 
> directory and thus only requests a listing of the path from the server. 

Ah, right.  Sorry.  Alzheimer is setting in early today. :-)

>   Otherwise it tries to get the file.  If that get fails (with a 550) it 
> then decides to try getting a listing for the path.  If that works it 
> returns that, otherwise it completely fails.
> 
> Basically I don't think there is a way to make this work for urllib 
> nicely.

Depends on what you call nicely.  I think of the current behavior as
"nice", because directories are a lot more common that files you can't
read in the typical ftp setup.

> If no one has any objections I will just clarify the docs 
> stating that if an attempt to get a file fails on a 550 error (and of 
> course I will say what that means) it will then try a LIST command and 
> if that succeeds that is what is returned.  And if you need more 
> fine-grained control then use ftplib.

Sounds good to me.  Thanks!

--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list