When using ftplib in python

Here is the corresponding code causing the error.

ftp = ftplib.FTP('server')
ftp.login(r'user', r'pass')

#change directories to the "incoming" folder
ftp.cwd('incoming')

fileObj = open(fromDirectory + os.sep + f, 'rb')

#push the file
try:
    msg = ftp.storbinary('STOR %s' % f, fileObj)
except Exception as inst:
    msg = inst
finally:
    fileObj.close()
    if '226' not in msg:
    #handle error case

I have never seen this error before, and any information on why I can get it will be helpful and appreciated.

full error message: [Errno 10060] Connection attempt failed because the connected side did not respond properly after some time or the connection failed because the connected host was unable to respond

It should be noted that when I manually (i.e. open dos-prompt and click files using ftp commands), click on the file from the same computer where the script is located, I have no problems.

+5
source share
2 answers

, ACTV, @Anders Lindahl, .

+1

, - " .

+1

All Articles