aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2015-01-02 18:50:57 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2015-01-02 18:50:57 +0100
commit847d9a66918290f465dfe9825005c3bda4f24c21 (patch)
treec4ab0392c1e1a63787cb3e9f55676dfd853cb350 /pyaggr3g470r
parentImport urlib.request for Python 3. (diff)
downloadnewspipe-847d9a66918290f465dfe9825005c3bda4f24c21.tar.gz
newspipe-847d9a66918290f465dfe9825005c3bda4f24c21.tar.bz2
newspipe-847d9a66918290f465dfe9825005c3bda4f24c21.zip
Hack: Re-add sslwrap to Python 2.7.9.
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/crawler.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/pyaggr3g470r/crawler.py b/pyaggr3g470r/crawler.py
index 2e07e844..812c9efe 100644
--- a/pyaggr3g470r/crawler.py
+++ b/pyaggr3g470r/crawler.py
@@ -61,6 +61,31 @@ logger = logging.getLogger(__name__)
socket.setdefaulttimeout(5.0)
+
+
+# Hack: Re-add sslwrap to Python 2.7.9
+import inspect
+__ssl__ = __import__('ssl')
+try:
+ _ssl = __ssl__._ssl
+except AttributeError:
+ _ssl = __ssl__._ssl2
+if not hasattr(_ssl, 'sslwrap'):
+ def new_sslwrap(sock, server_side=False, keyfile=None, certfile=None, cert_reqs=__ssl__.CERT_NONE, ssl_version=__ssl__.PROTOCOL_SSLv23, ca_certs=None, ciphers=None):
+ context = __ssl__.SSLContext(ssl_version)
+ context.verify_mode = cert_reqs or __ssl__.CERT_NONE
+ if ca_certs:
+ context.load_verify_locations(ca_certs)
+ if certfile:
+ context.load_cert_chain(certfile, keyfile)
+ if ciphers:
+ context.set_ciphers(ciphers)
+
+ caller_self = inspect.currentframe().f_back.f_locals['self']
+ return context._wrap_socket(sock, server_side=server_side, ssl_sock=caller_self)
+ _ssl.sslwrap = new_sslwrap
+
+
class TooLong(Exception):
def __init__(self):
"""
@@ -133,7 +158,6 @@ class FeedGetter(object):
"""
logger.info("Fetching the feed: " + feed.title)
a_feed = feedparser.parse(feed.link, handlers=[self.proxy])
- print(a_feed)
if a_feed['bozo'] == 1:
logger.error(a_feed['bozo_exception'])
if a_feed['entries'] == []:
bgstack15