[Twisted-Python] ftp client question
Michele Petrazzo
michele.petrazzo at unipex.it
Mon Jul 3 05:59:44 EDT 2006
Thomas Jacob wrote:
> On Sat, 2006-07-01 at 18:06 +0200, Michele Petrazzo wrote:
>> I have this code:
>>
>> creator = ClientCreator(reactor, FTPClient, self._user, self._passwd,
>> self._passive, fail=self._Fail)
>> cre = creator.connectTCP(self._host, self._port)
>> cre.addCallback(self._ConnectionMade)
>> cre.addErrback(self._Fail)
>>
>> I see that I can add a deferred on an connection error, that receive
>> also the commands error ("wrong user", etc..), but is there a solution
>> for add a callback for "user logged in" (code 230)?
>
> As far as I can see, _ConnectionMade is fired only when
> the login was successful (Code 230), no?
Not on my linux-box:
def conn():
creator = ClientCreator(reactor, FTPClient, self._user, self._passwd,
self._passive)
cre = creator.connectTCP(self._host, self._port)
cre.addCallback(self._ConnectionMade)
cre.addErrback(self._Fail)
def _ConnectionMade(self, ftpClient):
print "_ConnectionMade"
def _Fail(self, response):
print response.getTraceback()
michele:~$ python hylapex.py
_ConnectionMade
Traceback (most recent call last):
Failure: twisted.protocols.ftp.CommandFailed: ["500 'PASS ': Syntax
error, expecting password."]
May be that my server isn't a "real" server, but an "hylafax" server
that act like a ftp server?
> Isn't that all you need?
>
I need a function called after the "queueLogin" successfully called and
ended.
Something like this bad hack:
www.unipex.it/vario/myftp.py
that I use:
def conn():
creator = ClientCreator(reactor, FClient, self._user, self._passwd,
self._passive, self._loggedin)
cre = creator.connectTCP(self._host, self._port)
cre.addCallback(self._ConnectionMade)
cre.addErrback(self._Fail)
def _loggedin(self, res):
print res
self._loggedin = 1
def _ConnectionMade(self, ftpClient):
print "_ConnectionMade"
self._connected = 1
def _Fail(self, response):
print response.getTraceback()
michele:~$ python hylapex.py
_ConnectionMade
['230 User michele logged in.']
Michele
More information about the Twisted-Python
mailing list