i have error then use ftplib

  • Thread starter =?windows-1251?Q?=CB=E5=EE=ED=EE=E2_=C0=EB=E5=EA=F
  • Start date
?

=?windows-1251?Q?=CB=E5=EE=ED=EE=E2_=C0=EB=E5=EA=F

Hello!
I use this code:

from ftplib import FTP
def handleDownload(block):
file.write(block)
print "."

file = open('1', 'wb')
ftp = FTP('ftp.utk.ru')
ftp.set_pasv(1)
ftp.login()
ftp.retrlines('LIST')
ftp.cwd('users/video/Anime/Beyond the Clouds')
ftp.retrbinary('RETR "[Triad]_Beyond_the_Clouds_CD1.srt"', handleDownload, 1024, 600 )

ftp.quit()
file.close()


and have this error message.

Traceback (most recent call last):
File "ftp.py", line 10, in ?
ftp.retrlines('LIST')
File "C:\Python24\lib\ftplib.py", line 396, in retrlines
conn = self.transfercmd(cmd)
File "C:\Python24\lib\ftplib.py", line 345, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Python24\lib\ftplib.py", line 324, in ntransfercmd
conn.connect(sa)
File "<string>", line 1, in connect
socket.error: (10065, 'No route to host')


Programs that not use Python connect to the server ok.
Where I do mistake?

Best regards
nazarianin
 
S

Stefan Schwarzer

Hello nazarianin,

from ftplib import FTP
def handleDownload(block):
file.write(block)
print "."

file = open('1', 'wb')
ftp = FTP('ftp.utk.ru')
ftp.set_pasv(1)
ftp.login()
ftp.retrlines('LIST')
[...]
and have this error message.

Traceback (most recent call last):
File "ftp.py", line 10, in ?
ftp.retrlines('LIST')
[...]
socket.error: (10065, 'No route to host')

Programs that not use Python connect to the server ok.
Where I do mistake?

Are you sure that you don't need user and password arguments in
..login()? The documentation on ftplib says:

login([user[, passwd[, acct]]])
Log in as the given user. The passwd and acct parameters are
optional and default to the empty string. If no user is
specified, it defaults to 'anonymous'. If user is
'anonymous', the default passwd is 'anonymous@'. This
function should be called only once for each instance, after
a connection has been established; it should not be called at
all if a host and user were given when the instance was
created. Most FTP commands are only allowed after the client
has logged in.

Perhaps the server wasn't satisfied with your credentials and
closed the connection between the .login() and .retrlines()
calls?

Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,348
Messages
2,571,451
Members
48,795
Latest member
Lonell Lee

Latest Threads

Top