replace httplib with requests
This commit is contained in:
parent
ddef165e18
commit
8bccf7b2db
|
@ -50,7 +50,6 @@ from qrtextedit import ScanQRTextEdit, ShowQRTextEdit
|
|||
|
||||
from decimal import Decimal
|
||||
|
||||
import httplib
|
||||
import socket
|
||||
import webbrowser
|
||||
import csv
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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'):
|
||||
|
|
Loading…
Reference in New Issue