mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
replace httplib with requests
This commit is contained in:
parent
ddef165e18
commit
8bccf7b2db
4 changed files with 12 additions and 18 deletions
|
@ -50,7 +50,6 @@ from qrtextedit import ScanQRTextEdit, ShowQRTextEdit
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
import httplib
|
|
||||||
import socket
|
import socket
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import csv
|
import csv
|
||||||
|
|
|
@ -16,8 +16,10 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import threading, httplib, re, socket
|
import threading, re, socket
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import requests
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
import PyQt4.QtCore as QtCore
|
import PyQt4.QtCore as QtCore
|
||||||
|
@ -34,15 +36,13 @@ class VersionGetter(threading.Thread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
con = httplib.HTTPSConnection('electrum.org', timeout=5)
|
res = requests.request("GET", "https://electrum.org/version")
|
||||||
con.request("GET", "/version")
|
|
||||||
res = con.getresponse()
|
|
||||||
except socket.error as msg:
|
except socket.error as msg:
|
||||||
print_error("Could not retrieve version information")
|
print_error("Could not retrieve version information")
|
||||||
return
|
return
|
||||||
|
|
||||||
if res.status == 200:
|
if res.status_code == 200:
|
||||||
latest_version = res.read()
|
latest_version = res.text
|
||||||
latest_version = latest_version.replace("\n","")
|
latest_version = latest_version.replace("\n","")
|
||||||
if(re.match('^\d+(\.\d+)*$', latest_version)):
|
if(re.match('^\d+(\.\d+)*$', latest_version)):
|
||||||
self.label.callback(latest_version)
|
self.label.callback(latest_version)
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import httplib
|
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -60,10 +59,8 @@ import json
|
||||||
def get_payment_request(url):
|
def get_payment_request(url):
|
||||||
u = urlparse.urlparse(url)
|
u = urlparse.urlparse(url)
|
||||||
if u.scheme in ['http', 'https']:
|
if u.scheme in ['http', 'https']:
|
||||||
connection = httplib.HTTPConnection(u.netloc) if u.scheme == 'http' else httplib.HTTPSConnection(u.netloc)
|
response = requests.request('GET', url)
|
||||||
connection.request("GET", u.geturl(), headers=REQUEST_HEADERS)
|
data = response.content
|
||||||
response = connection.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
print_error('fetched payment request', url, len(data))
|
print_error('fetched payment request', url, len(data))
|
||||||
elif u.scheme == 'file':
|
elif u.scheme == 'file':
|
||||||
with open(u.path, 'r') as f:
|
with open(u.path, 'r') as f:
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
import httplib
|
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
import requests
|
||||||
|
|
||||||
from PyQt4.QtGui import QMessageBox, QApplication, QPushButton
|
from PyQt4.QtGui import QMessageBox, QApplication, QPushButton
|
||||||
|
|
||||||
|
@ -82,11 +82,9 @@ class Plugin(BasePlugin):
|
||||||
sig = self.wallet.sign_message(addr, message, password)
|
sig = self.wallet.sign_message(addr, message, password)
|
||||||
|
|
||||||
# 2. send the request
|
# 2. send the request
|
||||||
connection = httplib.HTTPSConnection('greenaddress.it')
|
response = requests.request("GET", ("/verify/?signature=%s&txhash=%s" % (urllib.quote(sig), tx.hash())),
|
||||||
connection.request("GET", ("/verify/?signature=%s&txhash=%s" % (urllib.quote(sig), tx.hash())),
|
headers = {'User-Agent': 'Electrum'})
|
||||||
None, {'User-Agent': 'Electrum'})
|
response = response.json()
|
||||||
response = connection.getresponse()
|
|
||||||
response = json.loads(response.read())
|
|
||||||
|
|
||||||
# 3. display the result
|
# 3. display the result
|
||||||
if response.get('verified'):
|
if response.get('verified'):
|
||||||
|
|
Loading…
Add table
Reference in a new issue