using python ftp

Giampaolo Rodolà g.rodola at gmail.com
Fri Dec 24 07:52:46 EST 2010


Starting from Python 2.7, yes:
http://docs.python.org/library/ftplib.html#ftplib.FTP_TLS

Regards,

--- Giampaolo
http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/



2010/12/23 Octavian Rasnita <orasnita at gmail.com>:
> Can this lib also work with ftps?
>
> Thanks.
>
> Octavian
>
> ----- Original Message -----
> From: "Anurag Chourasia" <anurag.chourasia at gmail.com>
> To: "Matt Funk" <mafunk at nmsu.edu>
> Cc: <python-list at python.org>
> Sent: Thursday, December 23, 2010 4:12 AM
> Subject: Re: using python ftp
>
>
>> Hi Matt,
>>
>> I have a snippet to "upload" files (that match a particular search
>> pattern) to a remote server.
>>
>> Variable names are self explanatory. You could tweak this a little to
>> "download" files instead.
>>
>> from ftplib import FTP
>> ftp = FTP(hostname)
>> ftp.login(user_id,passwd)
>> ftp.cwd(remote_directory)
>> files_list=glob.glob(file_search_pattern)
>> for file in files_list:
>>    try:
>>        ftp.storlines('STOR ' + file, open(file))
>>    except Exception, e:
>>        print ('Failed to FTP file: %s' %(file))
>> ftp.close()
>>
>> Regards,
>> Anurag
>>
>> On Thu, Dec 23, 2010 at 5:33 AM, Matt Funk <mafunk at nmsu.edu> wrote:
>>> Hi,
>>>
>>> i was wondering whether someone can point me whether the following
>>> already exists.
>>>
>>> I want to connect to a server , download various files (for whose name i
>>> want to be able to use a wildcard), and store those files in a given
>>> location on the hard drive. If the file already exists i do not want to
>>> download it.
>>>
>>> This seems fairly trivial and i would assume that there should be some
>>> sort of implementation that does this easily but i didn't find anything
>>> googling it.
>>>
>>> Otherwise i was going to do it "by hand" using ftplib:
>>> 1) connect to server,
>>> 2) change to directory on server
>>> 3) get listing
>>> 4) match the file pattern i want to the listing
>>> 5) check if file already exists
>>> 6) download file if matched and doesn't exist
>>>
>>> Can anyone offer any advice whether this already done somewhere?
>>>
>>> thanks
>>> matt
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list