commit 8bccf7b2db32f0fcc28eaaa2e03cfe6279e7978d
parent ddef165e18295af558b5a1777afe0c286b78f943
Author: ThomasV <thomasv@gitorious>
Date: Wed, 10 Jun 2015 08:29:50 +0200
replace httplib with requests
Diffstat:
4 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -50,7 +50,6 @@ from qrtextedit import ScanQRTextEdit, ShowQRTextEdit
from decimal import Decimal
-import httplib
import socket
import webbrowser
import csv
diff --git a/gui/qt/version_getter.py b/gui/qt/version_getter.py
@@ -16,8 +16,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import threading, httplib, re, socket
+import threading, re, socket
import webbrowser
+import requests
+
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore
@@ -34,15 +36,13 @@ class VersionGetter(threading.Thread):
def run(self):
try:
- con = httplib.HTTPSConnection('electrum.org', timeout=5)
- con.request("GET", "/version")
- res = con.getresponse()
+ res = requests.request("GET", "https://electrum.org/version")
except socket.error as msg:
print_error("Could not retrieve version information")
return
- if res.status == 200:
- latest_version = res.read()
+ if res.status_code == 200:
+ latest_version = res.text
latest_version = latest_version.replace("\n","")
if(re.match('^\d+(\.\d+)*$', latest_version)):
self.label.callback(latest_version)
diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py
@@ -18,7 +18,6 @@
import hashlib
-import httplib
import os.path
import re
import sys
@@ -60,10 +59,8 @@ import json
def get_payment_request(url):
u = urlparse.urlparse(url)
if u.scheme in ['http', 'https']:
- connection = httplib.HTTPConnection(u.netloc) if u.scheme == 'http' else httplib.HTTPSConnection(u.netloc)
- connection.request("GET", u.geturl(), headers=REQUEST_HEADERS)
- response = connection.getresponse()
- data = response.read()
+ response = requests.request('GET', url)
+ data = response.content
print_error('fetched payment request', url, len(data))
elif u.scheme == 'file':
with open(u.path, 'r') as f:
diff --git a/plugins/greenaddress_instant.py b/plugins/greenaddress_instant.py
@@ -17,9 +17,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import urllib
-import httplib
import json
import sys
+import requests
from PyQt4.QtGui import QMessageBox, QApplication, QPushButton
@@ -82,11 +82,9 @@ class Plugin(BasePlugin):
sig = self.wallet.sign_message(addr, message, password)
# 2. send the request
- connection = httplib.HTTPSConnection('greenaddress.it')
- connection.request("GET", ("/verify/?signature=%s&txhash=%s" % (urllib.quote(sig), tx.hash())),
- None, {'User-Agent': 'Electrum'})
- response = connection.getresponse()
- response = json.loads(response.read())
+ response = requests.request("GET", ("/verify/?signature=%s&txhash=%s" % (urllib.quote(sig), tx.hash())),
+ headers = {'User-Agent': 'Electrum'})
+ response = response.json()
# 3. display the result
if response.get('verified'):