i have error then use ftplib

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ëåîíîâ Àëåêñåé

    #1

    i have error then use ftplib

    Hello!
    I use this code:

    from ftplib import FTP
    def handleDownload( block):
    file.write(bloc k)
    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_Clo uds_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\li b\ftplib.py", line 396, in retrlines
    conn = self.transfercm d(cmd)
    File "C:\Python24\li b\ftplib.py", line 345, in transfercmd
    return self.ntransferc md(cmd, rest)[0]
    File "C:\Python24\li b\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

  • Stefan Schwarzer

    #2
    Re: i have error then use ftplib

    Hello nazarianin,

    On 2006-03-30 09:35, 5>=>2 ;5:A59 wrote:[color=blue]
    > from ftplib import FTP
    > def handleDownload( block):
    > file.write(bloc k)
    > print "."
    >
    > file = open('1', 'wb')
    > ftp = FTP('ftp.utk.ru ')
    > ftp.set_pasv(1)
    > ftp.login()
    > ftp.retrlines(' LIST')
    > [...][/color]
    [color=blue]
    > 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?[/color]

    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

    Comment

    Working...