Lukasa / requests-ftp

An FTP transport adapter for use with the Python Requests library.
Other
69 stars 25 forks source link

KeyError: 'GET' #3

Closed asmeurer closed 10 years ago

asmeurer commented 10 years ago

I am trying to use this at https://github.com/conda/conda/pull/682 to get FTP support for downloading. I am getting

 File "/Users/aaronmeurer/Documents/Continuum/conda/conda/connection.py", line 172, in send
    resp = self.func_table[request.method](path, request)
KeyError: 'GET'

(that corresponds to https://github.com/Lukasa/requests-ftp/blob/master/requests_ftp/ftp.py#L157).

Anyway way to support GET? Do I just need to mount this differently? I am currently doing self.mount("ftp://", FTPAdapter()) in my Session subclass.

Lukasa commented 10 years ago

Ah, so the FTP adapter uses the raw commands, not the ones exposed by FTP clients. The equivalent is actually RETR. You can make the adapter support GET by adding 'GET' to the func_table.

Lukasa commented 10 years ago

It should do the same as what RETR does.

asmeurer commented 10 years ago

So 'GET': self.retr wants to have some username and password.

asmeurer commented 10 years ago

If I add self.conn.login() before code = self.conn.retrbinary('RETR ' + path, data_callback_factory(data)) it works. Is this a good idea?

Lukasa commented 10 years ago

If you pass an Auth tuple to conn.get it'll work, I think. Just pass a tuple of empty strings.

asmeurer commented 10 years ago

I really have no idea about any of this. I'll just submit a PR and you can tell me if I am doing something stupid.

Lukasa commented 10 years ago

=) Sure.