[Twisted-Python] Ftp client

Michele Petrazzo michele.petrazzo at unipex.it
Thu Aug 4 05:30:43 EDT 2005

Andrew Bennetts wrote:
>>> Before connecting, can you add:
>>> FTPClient.debug = True
>>> Then we can see a full transcript of what's going on.
>> I add that line, but I can't see any new line except that I already
>> seen
> Odd.  It should log everything.

Strange. Do you want that I change something to understand the problem?
This happen also with the demo "ftpclient.py"!

>> Ok, but what I do with to make it work?
> Use FTPClient.list ;)

Obviously! :)

>> But what I receive is an empty file list

> Perhaps FTPFileListProtocol can't parse your file listing -- it tries
> to parse stuff more-or-less like:
> -rw-r--r--   1 root     other        531 Jan 29 03:26 README
> If you have another format, you'll need to write your own.  As a
> starting point, you could try:
> class LineRecorder(basic.LineReceiver): def connectionMade(self): 
> self.lines = [] def lineReceived(self,line): self.lines.append(line)
> Alternatively, subclass FTPFileListProtocol and override the
> unknownLine method.

With unknownLine overwritten I receive all the data correctly.

What the are more right way (the advice method) to proceed? Simple
override that method or create a new HylafaxFTPFileListProtocol ?

> Sorry, I was too hasty here -- you also need to change your errback
> to print failure.subFailure or perhaps failure.subFailure.subFailure
> rather than just failure.

After some code tries, I receive this response:
user login that has no password : [1]
user login with password, list of not exist directory: [2]

Like you can see, I must find the return errors inside the failure
instance at two differents point (I believe because, like you wrote,
there are several layers). You think that this "problem" will be fixed
in the future, for make the error more simple to understand?

I attach a diff file that solve my problem with the empty password and
the "PASS" command. For me it work well. I'll very happy if you include
my patch!

def fail(error):
     print error.value[1]

[Failure instance: Traceback (failure with no frames):
twisted.protocols.ftp.CommandFailed: ["500 'PASS ': Syntax error, 
expecting password."]

def fail(error):
     print error.value[0].value.subFailure

test_new_hylaproto.py:49: DeprecationWarning: FirstError.__getitem__ is 
deprecated.  Use attributes instead.
[Failure instance: Traceback (failure with no frames):
twisted.protocols.ftp.CommandFailed: ['550 pippo: No such file or 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff_ftp.diff
Type: text/x-patch
Size: 777 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20050804/01f8d34b/attachment.bin 

More information about the Twisted-Python mailing list