mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 02:35:20 +00:00
exchange_rates: use requests module
This commit is contained in:
parent
2bec9711cc
commit
77648c284f
1 changed files with 3 additions and 14 deletions
|
@ -3,7 +3,7 @@ from PyQt4.QtCore import *
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import decimal
|
import decimal
|
||||||
import httplib
|
import requests
|
||||||
import json
|
import json
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
@ -53,19 +53,8 @@ class Exchanger(threading.Thread):
|
||||||
self.is_running = False
|
self.is_running = False
|
||||||
|
|
||||||
def get_json(self, site, get_string):
|
def get_json(self, site, get_string):
|
||||||
try:
|
resp = requests.request('GET', 'https://' + site + get_string, headers={"User-Agent":"Electrum"})
|
||||||
connection = httplib.HTTPSConnection(site)
|
return resp.json()
|
||||||
connection.request("GET", get_string, headers={"User-Agent":"Electrum"})
|
|
||||||
except Exception:
|
|
||||||
raise
|
|
||||||
resp = connection.getresponse()
|
|
||||||
if resp.reason == httplib.responses[httplib.NOT_FOUND]:
|
|
||||||
raise
|
|
||||||
try:
|
|
||||||
json_resp = json.loads(resp.read())
|
|
||||||
except Exception:
|
|
||||||
raise
|
|
||||||
return json_resp
|
|
||||||
|
|
||||||
def exchange(self, btc_amount, quote_currency):
|
def exchange(self, btc_amount, quote_currency):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
|
Loading…
Add table
Reference in a new issue