0
I implemented a FTP Server in Python using pyftpdlib.ftpserver
This works fine with mput/put operations but fails with mget/get. Following exception is thrown:

[]10.203.200.136:62408 Connected. 10.203.200.136:62408 ==> 220 pyftpdlib 0.5.2 ready. 10.203.200.136:62408 <== USER user 10.203.200.136:62408 ==> 331 Username ok, send password. 10.203.200.136:62408 <== PASS ** 10.203.200.136:62408 ==> 230 Login successful. [user]@10.203.200.136:62408 User user logged in. 10.203.200.136:62408 <== TYPE A 10.203.200.136:62408 ==> 200 Type set to: ASCII. 10.203.200.136:62408 <== PORT 10,203,200,136,243,206 10.203.200.136:62408 ==> 200 Active data connection established. 10.203.200.136:62408 <== NLST RS.pcap [user]@10.203.200.136:62408 OK NLST "/RS.pcap". Transfer starting. 10.203.200.136:62408 ==> 125 Data connection already open. Transfer starting. 10.203.200.136:62408 ==> 226 Transfer complete. 10.203.200.136:62408 <== TYPE A 10.203.200.136:62408 ==> 200 Type set to: ASCII. 10.203.200.136:62408 <== PORT 10,203,200,136,243,208 10.203.200.136:62408 ==> 200 Active data connection established. 10.203.200.136:62408 <== RETR RS.pcap [user]@10.203.200.136:62408 OK RETR "/RS.pcap". Download starting. 10.203.200.136:62408 ==> 125 Data connection already open. Transfer starting. 10.203.200.136:62408 ==> 426 Internal error; transfer aborted.

Traceback (most recent call last):
    File "C:\Python31\lib\asynchat.py", line 244, in initiate_send
        data = buffer(first, 0, obs)
    File "C:\Python31\lib\asynchat.py", line 56, in buffer
        memoryview(obj)
TypeError: cannot make memory view because object does not have the buffer interface

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
    File "C:\Python31\lib\pyftpdlib\ftpserver.py", line 2077, in push_dtp_data
        self.data_channel.push_with_producer(data)
    File "C:\Python31\lib\asynchat.py", line 211, in push_with_producer
        self.initiate_send()
    File "C:\Python31\lib\asynchat.py", line 246, in initiate_send
        data = first.more()
    File "C:\Python31\lib\pyftpdlib\ftpserver.py", line 1143, in more
        return bytes(data, BYTES_ENCODING)
TypeError: encoding or errors without a string argument

Now in asynchat.py (which is called internally), in initiate_send, buffer is called which throws an exception when memoryview(obj) is done; obj being a FileProducer type of object.

Can anyone please suggest what possible error is it? Is there a problem in python library? How to solve it?

Confused
  • 617
  • 1
  • 9
  • 17

1 Answers1

0

Hard to say without seeing some actual code. It seems to be related to the str/bytes distinction (which has changed in Python 3 from Python 2). From the pyftpdlib homepage, it looks like pyftpdlib doesn't support Python 3 yet.

djc
  • 11,603
  • 5
  • 41
  • 54
  • I am using something like:from pyftpdlib import ftpserver>>> authorizer = ftpserver.DummyAuthorizer()>>> authorizer.add_user("user", "12345", "C:\Parent")>>> handler = ftpserver.FTPHandler>>> handler.authorizer = authorizer>>> address = ("10.203.20.136", 22)>>> ftpd = ftpserver.FTPServer(address, handler)>>> ftpd.serve_forever() – Confused Dec 03 '12 at 05:15