Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Distinguish file and folder on ftp site

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


lists at svrinformatica

Aug 14, 2008, 12:50 AM

Post #1 of 3 (240 views)
Permalink
Distinguish file and folder on ftp site

Hi,

is there a simple way to do this?

ftplib seems unable to distinguish between files and dir, a mimetype
check would be good,

regards
Nicola

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


fredrik at pythonware

Aug 14, 2008, 1:08 AM

Post #2 of 3 (212 views)
Permalink
Re: Distinguish file and folder on ftp site [In reply to]

Mailing List SVR wrote:

> is there a simple way to do this?
>
> ftplib seems unable to distinguish between files and dir, a mimetype
> check would be good,

the FTP protocol doesn't specify the format for the output from the LIST
command, so you have to use some heuristics; see e.g. the code in

http://svn.python.org/projects/python/trunk/Tools/scripts/ftpmirror.py

or use a wrapper for Dan Bernstein's ftpparse library (requires a C
compiler):

http://cr.yp.to/ftpparse.html
http://c0re.23.nu/c0de/ftpparsemodule/
http://effbot.org/downloads/#ftpparse

Not sure what you mean by "mimetype"; that has nothing to do with
directories vs. files, afaik.

</F>

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


lists at svrinformatica

Aug 21, 2008, 3:56 AM

Post #3 of 3 (187 views)
Permalink
Re: Distinguish file and folder on ftp site [In reply to]

Il giorno gio, 14/08/2008 alle 10.08 +0200, Fredrik Lundh ha scritto:
> Mailing List SVR wrote:
>
> > is there a simple way to do this?
> >
> > ftplib seems unable to distinguish between files and dir, a mimetype
> > check would be good,
>
> the FTP protocol doesn't specify the format for the output from the LIST
> command, so you have to use some heuristics; see e.g. the code in
>
> http://svn.python.org/projects/python/trunk/Tools/scripts/ftpmirror.py
>
> or use a wrapper for Dan Bernstein's ftpparse library (requires a C
> compiler):
>
> http://cr.yp.to/ftpparse.html
> http://c0re.23.nu/c0de/ftpparsemodule/
> http://effbot.org/downloads/#ftpparse
>

ftpparse seems broken, I found ftputil as the best solution,

thanks
Nicola

> Not sure what you mean by "mimetype"; that has nothing to do with
> directories vs. files, afaik.
>
> </F>
>
> --
> http://mail.python.org/mailman/listinfo/python-list

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

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.