[Yum-devel] [PATCH] Add generic option "curl_options". Helps BZ 849177
Zdenek Pavlas
zpavlas at redhat.com
Mon Apr 29 08:35:40 UTC 2013
---
urlgrabber/grabber.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index da15319..b4f6499 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -305,6 +305,14 @@ GENERAL ARGUMENTS (kwargs)
actually measured to the default speed, with default
period of 30 days.
+ curl_options = None
+
+ a list of key-value pairs to fine-tune the urlgrabber behavior.
+ For example, to turn off the FTP extended passive more,
+ you can use:
+
+ curl_options = ['FTP_USE_EPSV=0']
+
RETRY RELATED ARGUMENTS
@@ -981,6 +989,7 @@ class URLGrabberOptions:
self.timedhosts = None
self.half_life = 30*24*60*60 # 30 days
self.default_speed = 1e6 # 1 MBit
+ self.curl_options = None
def __repr__(self):
return self.format()
@@ -1406,6 +1415,17 @@ class PyCurlFileObject(object):
if opts.ssl_key_pass:
self.curl_obj.setopt(pycurl.SSLKEYPASSWD, opts.ssl_key_pass)
+ # custom curl options
+ for opt in opts.curl_options or []:
+ if isinstance(opt, tuple):
+ opt, value = opt
+ else:
+ opt, value = opt.split('=', 1)
+ opt = getattr(pycurl, opt)
+ try: value = int(value)
+ except: pass
+ self.curl_obj.setopt(opt, value)
+
#headers:
if opts.http_headers and self.scheme in ('http', 'https'):
headers = []
@@ -2027,6 +2047,7 @@ class _ExternalDownloader:
'ssl_key_pass',
'ssl_verify_peer', 'ssl_verify_host',
'size', 'max_header_size', 'ip_resolve',
+ 'curl_options',
)
def start(self, opts):
--
1.7.11.7
More information about the Yum-devel
mailing list