curl-and-python

Re: Curl RTSP Commands not Available in Python?

From: Nathan E. Moore <nate_at_redtetrahedron.org>
Date: Fri, 09 Mar 2012 10:01:10 -0500

On 3/9/2012 3:17 AM, Utsav Sabharwal wrote:
>>> To add the RTSP functionality to pycURL, is it a matter of adding the RTSP> > options to pycurl.c ?
>>>
>>> Example just adding the lines:
>>> insint_c(d, "RTSP_STREAM_URI", CURLOPT_RTSP_STREAM_URI);
>>> insint_c(d, "RTSP_REQUEST", CURLOPT_RTSP_REQUEST);
>> It might be worth to make some sort of (python?) script that extracts that
>> information from the public curl headers and generates the necessary glue code
>> from that, so it will be easier to just re-run it when new libcurl releases
>> ship!
>>
>> libcurl is known to release roughly every second month, and we add new options
>> rather frequently...
>>
>> --
>>
>> / daniel.haxx.se
>>
>>
> That sounds as a good idea.
> Right now the options are hard coded as per libcurl 7.19.0. Now the problem is each function of C API is mapped with Python API.
> For example:
>
> CURLOPT_URL is just called as url in pycURLExample:c.setopt(pycurl.URL, url)
> Reference: https://github.com/utsavsabharwal/Crawlers-Research-Arena/blob/master/curl/18/crawler.py
> Now, if the code automatically fetches the options from public curl headers then we shall loose the mapping.
> Pros:
> pycURL could be run with any version of libcurl without depreciating any feature.
> Rich libcurl documentation can be used for pycURL also.
> pycURL would not be called an old tool unfit for current internet tackling. Rather, without human support it would remain updated and syncd with libcurl
>
> Cons:
> The codes written in previous pycURL version would not run with the new version
> Users who only use pycURL must now learn libcurl commands which differ from current
> pycURL commands but learning it can make them capable to use C API in future with ease. :p
>
>
> p,s,: Taking into consideration frequency of libcurl updates and lack of manpower @ pycURL developers I feel making this change would be good.
>
To allow for renaming the constants without breaking old code this could
be done.
1) move old constants to a sub module -- example name pycurl.old_constants
2) define new constants in a sub module -- example name
pycurl.current_constants
3) create yet another module named something like pycurlbackcompat that
defines a single Boolean constant name used_old_constants defaulting to
False.
4) in pycurl upon import: import and check the value of
pycurl.backcompat.use_old_constants. If True issue a deprecation warning
and import * from pycurl.old_constants. If False (the default) do import
* from pycurl.current_constants.

While this still introduces a breaking change, the fix to keep old code
working is only two line long. Which is much better than having to
change ever place you used a constant.

I believe this can all be done via the python c api, and I know it can
be in python.

Nathan Moore
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2012-03-09