An FTP Client...My first real program!

tmallen thomasmallen at gmail.com
Thu Aug 14 09:56:05 EDT 2008


On Aug 14, 9:54 am, tmallen <thomasmal... at gmail.com> wrote:
> On Aug 13, 11:53 pm, "Python Nutter" <pythonnut... at gmail.com> wrote:
>
>
>
> > sorry cut off due to original email being sent not to the list due to gmail:
>
> > A second for that suggestion--the ftp module in the python standard library is
> > very low level and not very useful for beginners as a lot of the heavy
> > lifting and management is still left up to you, the programmer.
>
> > 2008/8/14 Python Nutter <pythonnut... at gmail.com>:
>
> > > ery low level and not very useful for beginners as a lot of the heavy
> > > lifting and management is still left up to you, the programmer.
>
> > > The module ftputil is a high-level interface to the ftplib module. The
> > > FTPHost objects generated from it allow many operations similar to
> > > those of os and os.path. An example:
>
> > > # download some files from the login directory
> > > host = ftputil.FTPHost('ftp.domain.com', 'user', 'secret')
> > > names = host.listdir(host.curdir)
> > > for name in names:
> > >   if host.path.isfile(name):
> > >       host.download(name, name, 'b')  # remote, local, binary mode
> > > # make a new directory and copy a remote file into it
> > > host.mkdir('newdir')
> > > source = host.file('index.html', 'r')  # file-like object
> > > target = host.file('newdir/index.html', 'w')  # file-like object
> > > host.copyfileobj(source, target)  # similar to shutil.copyfileobj
> > > source.close()
> > > target.close()
>
> > > Now if you are again purely in it for a challenge or for and
> > > educational roller coaster ride, ignore the suggestion to look at
> > > higher level ftp modules =)
>
> > > Cheers,
> > > PN
>
> What work, specifically, am I duplicating? I have my eyes on a larger
> application, so if this part can easily be taken care of, I'm all ears.

I see that there's this ftputil module. Are there any modules already
written for other clients, e.g. CVS, Subversion, Git, etc?



More information about the Python-list mailing list