[Python-modules-commits] [pycurl] 81/140: Import pycurl_7.18.2.orig.tar.gz

Barry Warsaw barry at moszumanska.debian.org
Wed Oct 1 21:45:10 UTC 2014


This is an automated email from the git hooks/post-receive script.

barry pushed a commit to branch master
in repository pycurl.

commit b15d5935a2bd177c8f8a82837bfc8751c7a44184
Author: Barry Warsaw <barry at python.org>
Date:   Wed Oct 1 16:43:45 2014 -0400

    Import pycurl_7.18.2.orig.tar.gz
---
 ChangeLog                         |  21 +++++++-
 PKG-INFO                          |   2 +-
 setup.py                          |   6 +--
 setup_win32_ssl.py                |   4 +-
 src/pycurl.c                      |  78 +++++++++++++++++++++++++---
 tests/test_multi_socket_select.py | 105 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 201 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c605279..8df1dbe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,21 @@
-Version 7.18.1 [requires libcurl-7.18.1 or better]
+Version 7.18.2 [requires libcurl-7.18.2 or better]
+--------------
+
+        * Added REDIRECT_URL info and M_MAXCONNECTS option
+          (patch by Yuhui H <eyecat at gmail.com>).
+
+        * Added socket_action() method to CurlMulti objects.
+          See 'tests/test_multi_socket_select.py' for example
+          usage (patch by Yuhui H <eyecat at gmail.com>).
+
+        * Added AUTOREFERER option.
+
+        * Allow resetting some list operations (HTTPHEADER,
+          QUOTE, POSTQUOTE, PREQUOTE) by passing an empty
+          list to setopt (patch by Jim Patterson).
+
+
+Version 7.18.1
 --------------
 
         * Added POST301, SSH_HOST_PUBLIC_KEY_MD5,
@@ -9,7 +26,7 @@ Version 7.18.1 [requires libcurl-7.18.1 or better]
 
         * PycURL is now dual licensed under the LGPL and
           a license similar to the cURL license (an MIT/X
-          derivate).
+          derivative).
 
 
 Version 7.16.4
diff --git a/PKG-INFO b/PKG-INFO
index 47238d3..0d56b89 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: pycurl
-Version: 7.18.1
+Version: 7.18.2
 Summary: PycURL -- cURL library module for Python
 Home-page: http://pycurl.sourceforge.net/
 Author: Kjetil Jacobsen, Markus F.X.J. Oberhumer
diff --git a/setup.py b/setup.py
index d0df478..928ce10 100644
--- a/setup.py
+++ b/setup.py
@@ -1,13 +1,13 @@
 #! /usr/bin/env python
 # -*- coding: iso-8859-1 -*-
 # vi:ts=4:et
-# $Id: setup.py,v 1.147 2008/04/22 14:00:45 kjetilja Exp $
+# $Id: setup.py,v 1.149 2008/06/12 18:01:53 kjetilja Exp $
 
 """Setup script for the PycURL module distribution."""
 
 PACKAGE = "pycurl"
 PY_PACKAGE = "curl"
-VERSION = "7.18.1"
+VERSION = "7.18.2"
 
 import glob, os, re, sys, string
 import distutils
@@ -69,7 +69,7 @@ if sys.platform == "win32":
     assert os.path.isdir(CURL_DIR), "please check CURL_DIR in setup.py"
     include_dirs.append(os.path.join(CURL_DIR, "include"))
     extra_objects.append(os.path.join(CURL_DIR, "lib", "libcurl.lib"))
-    extra_link_args.extend(["gdi32.lib", "winmm.lib", "ws2_32.lib",])
+    extra_link_args.extend(["gdi32.lib", "wldap32.lib", "winmm.lib", "ws2_32.lib",])
     add_libdirs("LIB", ";")
     if string.find(sys.version, "MSC") >= 0:
         extra_compile_args.append("-O2")
diff --git a/setup_win32_ssl.py b/setup_win32_ssl.py
index 18406d2..2299e99 100644
--- a/setup_win32_ssl.py
+++ b/setup_win32_ssl.py
@@ -1,13 +1,13 @@
 #! /usr/bin/env python
 # -*- coding: iso-8859-1 -*-
 # vi:ts=4:et
-# $Id: setup_win32_ssl.py,v 1.43 2008/04/22 13:47:15 kjetilja Exp $
+# $Id: setup_win32_ssl.py,v 1.44 2008/06/12 18:01:53 kjetilja Exp $
 
 import os, sys, string
 assert sys.platform == "win32", "Only for building on Win32 with SSL and zlib"
 
 
-CURL_DIR = r"c:\src\build\pycurl\curl-7.18.1-ssl"
+CURL_DIR = r"c:\src\build\pycurl\curl-7.18.2-ssl"
 OPENSSL_DIR = r"c:\src\build\pycurl\openssl-0.9.7g"
 sys.argv.insert(1, "--curl-dir=" + CURL_DIR)
 
diff --git a/src/pycurl.c b/src/pycurl.c
index 0ea0f69..1204ab5 100644
--- a/src/pycurl.c
+++ b/src/pycurl.c
@@ -1,10 +1,12 @@
-/* $Id: pycurl.c,v 1.138 2008/04/22 13:47:15 kjetilja Exp $ */
+/* $Id: pycurl.c,v 1.143 2008/06/12 18:01:53 kjetilja Exp $ */
 
 /* PycURL -- cURL Python module
  *
  * Authors:
- *  Copyright (C) 2001-2007 by Kjetil Jacobsen <kjetilja at gmail.com>
- *  Copyright (C) 2001-2007 by Markus F.X.J. Oberhumer <markus at oberhumer.com>
+ *  Copyright (C) 2001-2008 by Kjetil Jacobsen <kjetilja at gmail.com>
+ *  Copyright (C) 2001-2008 by Markus F.X.J. Oberhumer <markus at oberhumer.com>
+ *
+ *  All rights reserved.
  *
  * Contributions:
  *  Tino Lange <Tino.Lange at gmx.de>
@@ -22,7 +24,9 @@
  *  Bastian Kleineidam
  *  Mark Eichin
  *  Aaron Hill <visine19 at hotmail.com>
- *  Daniel Pena Arteaga <dpena ph.tum.de>
+ *  Daniel Pena Arteaga <dpena at ph.tum.de>
+ *  Jim Patterson
+ *  Yuhui H <eyecat at gmail.com>
  *
  * See file README for license information.
  */
@@ -51,8 +55,8 @@
 #if !defined(PY_VERSION_HEX) || (PY_VERSION_HEX < 0x02020000)
 #  error "Need Python version 2.2 or greater to compile pycurl."
 #endif
-#if !defined(LIBCURL_VERSION_NUM) || (LIBCURL_VERSION_NUM < 0x071201)
-#  error "Need libcurl version 7.18.1 or greater to compile pycurl."
+#if !defined(LIBCURL_VERSION_NUM) || (LIBCURL_VERSION_NUM < 0x071202)
+#  error "Need libcurl version 7.18.2 or greater to compile pycurl."
 #endif
 
 /* Python < 2.5 compat for Py_ssize_t */
@@ -1711,6 +1715,14 @@ do_curl_setopt(CurlObject *self, PyObject *args)
         len = PyList_Size(obj);
         if (len == 0) {
             /* Empty list - do nothing */
+            if (!(option == CURLOPT_HTTPHEADER ||
+                  option == CURLOPT_QUOTE ||
+                  option == CURLOPT_POSTQUOTE ||
+                  option == CURLOPT_PREQUOTE)) {
+                /* Empty list - do nothing */
+                Py_INCREF(Py_None);
+                return Py_None;
+            }
             Py_INCREF(Py_None);
             return Py_None;
         }
@@ -2058,6 +2070,7 @@ do_curl_getinfo(CurlObject *self, PyObject *args)
     case CURLINFO_CONTENT_TYPE:
     case CURLINFO_EFFECTIVE_URL:
     case CURLINFO_FTP_ENTRY_PATH:
+    case CURLINFO_REDIRECT_URL:
         {
             /* Return PyString as result */
             char *s_res = NULL;
@@ -2344,6 +2357,9 @@ do_multi_setopt(CurlMultiObject *self, PyObject *args)
         case CURLMOPT_PIPELINING:
             curl_multi_setopt(self->multi_handle, option, d);
             break;
+        case CURLMOPT_MAXCONNECTS:
+            curl_multi_setopt(self->multi_handle, option, d);
+            break;
         default:
             PyErr_SetString(PyExc_TypeError, "integers are not supported for this option");
             return NULL;
@@ -2434,6 +2450,36 @@ do_multi_assign(CurlMultiObject *self, PyObject *args)
 }
 
 
+/* --------------- socket_action --------------- */
+static PyObject *
+do_multi_socket_action(CurlMultiObject *self, PyObject *args)
+{
+    CURLMcode res;
+    curl_socket_t socket;
+    int ev_bitmask;
+    int running = -1;
+    
+    if (!PyArg_ParseTuple(args, "ii:socket_action", &socket, &ev_bitmask))
+        return NULL;
+    if (check_multi_state(self, 1 | 2, "socket_action") != 0) {
+        return NULL;
+    }
+    /* Release global lock and start */
+    self->state = PyThreadState_Get();
+    assert(self->state != NULL);
+    Py_BEGIN_ALLOW_THREADS
+
+    res = curl_multi_socket_action(self->multi_handle, socket, ev_bitmask, &running);
+    Py_END_ALLOW_THREADS
+    self->state = NULL;
+
+    if (res != CURLM_OK) {
+        CURLERROR_MSG("multi_socket_action failed");
+    }
+    /* Return a tuple with the result and the number of running handles */
+    return Py_BuildValue("(ii)", (int)res, running);
+}
+
 /* --------------- socket_all --------------- */
 
 static PyObject *
@@ -2799,6 +2845,8 @@ static char co_unsetopt_doc [] = "unsetopt(option) -> None.  Reset curl session
 static char co_multi_fdset_doc [] = "fdset() -> Tuple.  Returns a tuple of three lists that can be passed to the select.select() method .\n";
 static char co_multi_info_read_doc [] = "info_read([max_objects]) -> Tuple. Returns a tuple (number of queued handles, [curl objects]).\n";
 static char co_multi_select_doc [] = "select([timeout]) -> Int.  Returns result from doing a select() on the curl multi file descriptor with the given timeout.\n";
+static char co_multi_socket_action_doc [] = "socket_action(sockfd, ev_bitmask) -> Tuple.  Returns result from doing a socket_action() on the curl multi file descriptor with the given timeout.\n";
+static char co_multi_socket_all_doc [] = "socket_all() -> Tuple.  Returns result from doing a socket_all() on the curl multi file descriptor with the given timeout.\n";
 
 static PyMethodDef curlshareobject_methods[] = {
     {"setopt", (PyCFunction)do_curlshare_setopt, METH_VARARGS, cso_setopt_doc},
@@ -2821,7 +2869,8 @@ static PyMethodDef curlmultiobject_methods[] = {
     {"fdset", (PyCFunction)do_multi_fdset, METH_NOARGS, co_multi_fdset_doc},
     {"info_read", (PyCFunction)do_multi_info_read, METH_VARARGS, co_multi_info_read_doc},
     {"perform", (PyCFunction)do_multi_perform, METH_NOARGS, NULL},
-    {"socket_all", (PyCFunction)do_multi_socket_all, METH_NOARGS, NULL},
+    {"socket_action", (PyCFunction)do_multi_socket_action, METH_VARARGS, co_multi_socket_action_doc},
+    {"socket_all", (PyCFunction)do_multi_socket_all, METH_NOARGS, co_multi_socket_all_doc},
     {"setopt", (PyCFunction)do_multi_setopt, METH_VARARGS, NULL},
     {"timeout", (PyCFunction)do_multi_timeout, METH_NOARGS, NULL},
     {"assign", (PyCFunction)do_multi_assign, METH_VARARGS, NULL},
@@ -3575,10 +3624,12 @@ initpycurl(void)
     insint_c(d, "PROXY_TRANSFER_MODE", CURLOPT_PROXY_TRANSFER_MODE);
     insint_c(d, "COPYPOSTFIELDS", CURLOPT_COPYPOSTFIELDS);
     insint_c(d, "SSH_HOST_PUBLIC_KEY_MD5", CURLOPT_SSH_HOST_PUBLIC_KEY_MD5);
+    insint_c(d, "AUTOREFERER", CURLOPT_AUTOREFERER);
 
     insint_c(d, "M_TIMERFUNCTION", CURLMOPT_TIMERFUNCTION);
     insint_c(d, "M_SOCKETFUNCTION", CURLMOPT_SOCKETFUNCTION);
     insint_c(d, "M_PIPELINING", CURLMOPT_PIPELINING);
+    insint_c(d, "M_MAXCONNECTS", CURLMOPT_MAXCONNECTS);
 
     /* constants for setopt(IPRESOLVE, x) */
     insint_c(d, "IPRESOLVE_WHATEVER", CURL_IPRESOLVE_WHATEVER);
@@ -3639,6 +3690,7 @@ initpycurl(void)
     insint_c(d, "CONTENT_TYPE", CURLINFO_CONTENT_TYPE);
     insint_c(d, "REDIRECT_TIME", CURLINFO_REDIRECT_TIME);
     insint_c(d, "REDIRECT_COUNT", CURLINFO_REDIRECT_COUNT);
+    insint_c(d, "REDIRECT_URL", CURLINFO_REDIRECT_URL);
     insint_c(d, "HTTP_CONNECTCODE", CURLINFO_HTTP_CONNECTCODE);
     insint_c(d, "HTTPAUTH_AVAIL", CURLINFO_HTTPAUTH_AVAIL);
     insint_c(d, "PROXYAUTH_AVAIL", CURLINFO_PROXYAUTH_AVAIL);
@@ -3656,6 +3708,18 @@ initpycurl(void)
     insint(d, "GLOBAL_NOTHING", CURL_GLOBAL_NOTHING);
     insint(d, "GLOBAL_DEFAULT", CURL_GLOBAL_DEFAULT);
 
+
+    /* constants for curl_multi_socket interface */
+    insint(d, "CSELECT_IN", CURL_CSELECT_IN);
+    insint(d, "CSELECT_OUT", CURL_CSELECT_OUT);
+    insint(d, "CSELECT_ERR", CURL_CSELECT_ERR);
+    insint(d, "SOCKET_TIMEOUT", CURL_SOCKET_TIMEOUT);
+    insint(d, "POLL_NONE", CURL_POLL_NONE);
+    insint(d, "POLL_IN", CURL_POLL_IN);
+    insint(d, "POLL_OUT", CURL_POLL_OUT);
+    insint(d, "POLL_INOUT", CURL_POLL_INOUT);
+    insint(d, "POLL_REMOVE", CURL_POLL_REMOVE);
+
     /* curl_lock_data: XXX do we need this in pycurl ??? */
     /* curl_lock_access: XXX do we need this in pycurl ??? */
     /* CURLSHcode: XXX do we need this in pycurl ??? */
diff --git a/tests/test_multi_socket_select.py b/tests/test_multi_socket_select.py
new file mode 100644
index 0000000..d8c8e8a
--- /dev/null
+++ b/tests/test_multi_socket_select.py
@@ -0,0 +1,105 @@
+#! /usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+# vi:ts=4:et
+# $Id: test_multi_socket_select.py,v 1.1 2008/06/11 18:11:46 kjetilja Exp $
+
+import os, sys
+try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
+import pycurl
+import select
+
+sockets = set()
+timeout = 0
+
+urls = (
+    "http://curl.haxx.se",
+    "http://www.python.org",
+    "http://pycurl.sourceforge.net",
+)
+
+# Read list of URIs from file specified on commandline
+try:
+    urls = open(sys.argv[1], "rb").readlines()
+except IndexError:
+    # No file was specified
+    pass
+
+# timer callback
+def timer(msecs):
+    global timeout
+    timeout = msecs
+    print 'Timer callback msecs:', msecs
+
+# socket callback
+def socket(event, socket, multi, data):
+    if event == pycurl.POLL_REMOVE:
+        print "Remove Socket %d"%socket
+        sockets.remove(socket)
+    else:
+        if socket not in sockets:
+            print "Add socket %d"%socket
+            sockets.add(socket)
+    print event, socket, multi, data
+
+# init
+m = pycurl.CurlMulti()
+m.setopt(pycurl.M_PIPELINING, 1)
+m.setopt(pycurl.M_TIMERFUNCTION, timer)
+m.setopt(pycurl.M_SOCKETFUNCTION, socket)
+m.handles = []
+for url in urls:
+    c = pycurl.Curl()
+    # save info in standard Python attributes
+    c.url = url
+    c.body = StringIO()
+    c.http_code = -1
+    m.handles.append(c)
+    # pycurl API calls
+    c.setopt(c.URL, c.url)
+    c.setopt(c.WRITEFUNCTION, c.body.write)
+    m.add_handle(c)
+
+# get data
+num_handles = len(m.handles)
+
+while (pycurl.E_CALL_MULTI_PERFORM==m.socket_all()[0]):
+    pass
+    
+timeout = m.timeout()
+
+
+while True:
+    (rr, wr, er) = select.select(sockets,sockets,sockets,timeout/1000.0)
+    socketSet = set(rr+wr+er)
+    if socketSet:
+        for s in socketSet:
+            while True:
+                (ret,running) = m.socket_action(s,0)
+                if ret!=pycurl.E_CALL_MULTI_PERFORM:
+                    break
+    else:
+        (ret,running) = m.socket_action(pycurl.SOCKET_TIMEOUT,0)
+    if running==0:
+        break
+
+# close handles
+for c in m.handles:
+    # save info in standard Python attributes
+    c.http_code = c.getinfo(c.HTTP_CODE)
+    # pycurl API calls
+    m.remove_handle(c)
+    c.close()
+m.close()
+
+# print result
+for c in m.handles:
+    data = c.body.getvalue()
+    if 0:
+        print "**********", c.url, "**********"
+        print data
+    else:
+        print "%-53s http_code %3d, %6d bytes" % (c.url, c.http_code, len(data))
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pycurl.git



More information about the Python-modules-commits mailing list