command_ftpget: Wrap ftp.quit() into try/except (#576)

This commit is contained in:
fe7ch
2017-09-12 20:09:39 +03:00
committed by Michel Oosterhof
parent f4c53a98db
commit cc7f93b121

View File

@ -8,6 +8,7 @@ import re
import time import time
import getopt import getopt
import hashlib import hashlib
import socket
from ftplib import FTP from ftplib import FTP
from twisted.python import log from twisted.python import log
@ -169,7 +170,10 @@ Download a file via FTP
except Exception as e: except Exception as e:
log.msg('FTP login failed: user=%s, passwd=%s, err=%s' % (self.username, self.password, str(e))) log.msg('FTP login failed: user=%s, passwd=%s, err=%s' % (self.username, self.password, str(e)))
self.write('ftpget: unexpected server response to USER: %s\n' % str(e)) self.write('ftpget: unexpected server response to USER: %s\n' % str(e))
ftp.quit() try:
ftp.quit()
except socket.timeout:
pass
return False return False
# download # download
@ -185,7 +189,10 @@ Download a file via FTP
except Exception as e: except Exception as e:
log.msg('FTP retrieval failed: %s' % str(e)) log.msg('FTP retrieval failed: %s' % str(e))
self.write('ftpget: unexpected server response to USER: %s\n' % str(e)) self.write('ftpget: unexpected server response to USER: %s\n' % str(e))
ftp.quit() try:
ftp.quit()
except socket.timeout:
pass
return False return False
# quit # quit
@ -193,7 +200,11 @@ Download a file via FTP
self.write('ftpget: cmd (null) (null)\n') self.write('ftpget: cmd (null) (null)\n')
self.write('ftpget: cmd QUIT (null)\n') self.write('ftpget: cmd QUIT (null)\n')
ftp.quit() try:
ftp.quit()
except socket.timeout:
pass
return True return True