The Artima Developer Community
Sponsored Link

Python Answers Forum
can't find a needed method in ftplib

1 reply on 1 page. Most recent reply: Oct 10, 2005 12:18 PM by Kristina Kudriasova

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Kristina Kudriasova

Posts: 2
Nickname: ristinak
Registered: Oct, 2005

can't find a needed method in ftplib Posted: Oct 5, 2005 11:15 AM
Reply to this message Reply
Advertisement
Hi to all,
sorry for asking such a question, but I've been exploring the ftplib documentation since last week and could't find a method that would help me download a file from the server and save it on my PC. I've tried retrlines() and retrbinary(), but the best that I could get was a file printed out in the screen (and actually, I can't remember how I did that).

If somebody has the experience in working with ftplib module, please help.


Kristina Kudriasova

Posts: 2
Nickname: ristinak
Registered: Oct, 2005

Re: can't find a needed method in ftplib Posted: Oct 10, 2005 12:18 PM
Reply to this message Reply
I found it!
<pre>
>>> from ftplib import FTP
>>> ftp = FTP('<u>some_port</u>')
>>> ftp.login(<u>some_user</u>, <u>some_password</u>)
'230 user <u>some_user</u> logged in.'
>>> def callback(block):
... f = open('<u>some_file</u>', 'a')
... print >> f, str(block)
... f.close()
...
>>> ftp.retrbinary('RETR <u>some_path</u>', callback)
'226 Transfer complete.'
</pre>

Flat View: This topic has 1 reply on 1 page
Topic: Log Console output Previous Topic   Next Topic Topic: Help with Questor.py code

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use