Added an optional timeout parameter to urllib.ftpwrapper, with tests

(for this and a basic one, because there weren't any). Changed also
NEWS, but didn't find documentation for this function, assumed it
wasn't public...
This commit is contained in:
Facundo Batista 2007-05-24 17:50:54 +00:00
parent dd96ca3d6b
commit 711a54ebde
3 changed files with 71 additions and 3 deletions

View file

@ -819,19 +819,20 @@ def noheaders():
class ftpwrapper:
"""Class used by open_ftp() for cache of open FTP connections."""
def __init__(self, user, passwd, host, port, dirs):
def __init__(self, user, passwd, host, port, dirs, timeout=None):
self.user = user
self.passwd = passwd
self.host = host
self.port = port
self.dirs = dirs
self.timeout = timeout
self.init()
def init(self):
import ftplib
self.busy = 0
self.ftp = ftplib.FTP()
self.ftp.connect(self.host, self.port)
self.ftp.connect(self.host, self.port, self.timeout)
self.ftp.login(self.user, self.passwd)
for dir in self.dirs:
self.ftp.cwd(dir)