electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 77648c284f069b743edd5df38f7bbee85be00a2d
parent 2bec9711ccb8cb4122390349ced9bd3e9608538b
Author: ThomasV <thomasv@gitorious>
Date:   Tue, 28 Apr 2015 06:28:20 +0200

exchange_rates: use requests module

Diffstat:
Mplugins/exchange_rate.py | 17+++--------------
1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py @@ -3,7 +3,7 @@ from PyQt4.QtCore import * import datetime import decimal -import httplib +import requests import json import threading import time @@ -53,19 +53,8 @@ class Exchanger(threading.Thread): self.is_running = False def get_json(self, site, get_string): - try: - connection = httplib.HTTPSConnection(site) - 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 + resp = requests.request('GET', 'https://' + site + get_string, headers={"User-Agent":"Electrum"}) + return resp.json() def exchange(self, btc_amount, quote_currency): with self.lock: