2000-02-26 10:24:46 +00:00
|
|
|
import ftplib
|
|
|
|
|
from UrlData import UrlData
|
|
|
|
|
|
|
|
|
|
class FtpUrlData(UrlData):
|
|
|
|
|
"""
|
|
|
|
|
Url link with ftp scheme.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def checkConnection(self, config):
|
2000-03-07 22:47:50 +00:00
|
|
|
_user, _password = self._getUserPassword(config)
|
|
|
|
|
self.urlConnection = ftplib.FTP(self.urlTuple[1], _user, _password)
|
2000-02-26 10:24:46 +00:00
|
|
|
info = self.urlConnection.getwelcome()
|
|
|
|
|
if not info:
|
|
|
|
|
self.closeConnection()
|
|
|
|
|
raise Exception, "Got no answer from FTP server"
|
|
|
|
|
self.setInfo(info)
|
|
|
|
|
|
|
|
|
|
def closeConnection(self):
|
|
|
|
|
try: self.urlConnection.quit()
|
|
|
|
|
except: pass
|
|
|
|
|
self.urlConnection = None
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return "FTP link\n"+UrlData.__str__(self)
|
|
|
|
|
|
|
|
|
|
|