[Reportbug-commits] [reportbug] 05/32: replace urllib with requests, and disable proxy handling
Sandro Tosi
morph at moszumanska.debian.org
Thu Dec 1 01:36:51 UTC 2016
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository reportbug.
commit 5cf006943001a94bfafe0a40adbb1241950853de
Author: Sandro Tosi <morph at debian.org>
Date: Sun Sep 4 20:13:06 2016 +0100
replace urllib with requests, and disable proxy handling
---
reportbug/urlutils.py | 43 +++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/reportbug/urlutils.py b/reportbug/urlutils.py
index f80d1c7..310a69a 100644
--- a/reportbug/urlutils.py
+++ b/reportbug/urlutils.py
@@ -31,6 +31,7 @@ import subprocess
import os
import sys
import webbrowser
+import requests
from .exceptions import (
NoNetwork,
@@ -111,26 +112,28 @@ def urlopen(url, proxies=None, timeout=60, data=None):
headers = {'User-Agent': UA_STR,
'Accept-Encoding': 'gzip;q=1.0, deflate;q=0.9, identity;q=0.5'}
- req = urllib.request.Request(url, data, headers)
-
- proxy_support = urllib.request.ProxyHandler(proxies)
- if _opener is None:
- pwd_manager = handlepasswd()
- handlers = [proxy_support,
- urllib.request.UnknownHandler, HttpWithGzipHandler,
- urllib.request.HTTPBasicAuthHandler(pwd_manager),
- urllib.request.ProxyBasicAuthHandler(pwd_manager),
- urllib.request.HTTPDigestAuthHandler(pwd_manager),
- urllib.request.ProxyDigestAuthHandler(pwd_manager),
- urllib.request.HTTPDefaultErrorHandler, urllib.request.HTTPRedirectHandler,
- ]
- if hasattr(http.client, 'HTTPS'):
- handlers.append(HttpsWithGzipHandler)
- _opener = urllib.request.build_opener(*handlers)
- # print _opener.handlers
- urllib.request.install_opener(_opener)
-
- return _opener.open(req, timeout=timeout)
+ return requests.get(url, headers).text
+
+ # req = urllib.request.Request(url, data, headers)
+ #
+ # proxy_support = urllib.request.ProxyHandler(proxies)
+ # if _opener is None:
+ # pwd_manager = handlepasswd()
+ # handlers = [proxy_support,
+ # urllib.request.UnknownHandler, HttpWithGzipHandler,
+ # urllib.request.HTTPBasicAuthHandler(pwd_manager),
+ # urllib.request.ProxyBasicAuthHandler(pwd_manager),
+ # urllib.request.HTTPDigestAuthHandler(pwd_manager),
+ # urllib.request.ProxyDigestAuthHandler(pwd_manager),
+ # urllib.request.HTTPDefaultErrorHandler, urllib.request.HTTPRedirectHandler,
+ # ]
+ # if hasattr(http.client, 'HTTPS'):
+ # handlers.append(HttpsWithGzipHandler)
+ # _opener = urllib.request.build_opener(*handlers)
+ # # print _opener.handlers
+ # urllib.request.install_opener(_opener)
+ #
+ # return _opener.open(req, timeout=timeout)
# Global useful URL opener; returns None if the page is absent, otherwise
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reportbug/reportbug.git
More information about the Reportbug-commits
mailing list