|
|
@ -16,6 +16,7 @@ from electrum import ecc |
|
|
|
from electrum.i18n import _ |
|
|
|
from electrum.util import make_aiohttp_session |
|
|
|
from electrum.logging import Logger |
|
|
|
from electrum.network import Network |
|
|
|
|
|
|
|
|
|
|
|
class UpdateCheck(QDialog, Logger): |
|
|
@ -26,8 +27,7 @@ class UpdateCheck(QDialog, Logger): |
|
|
|
"13xjmVAB1EATPP8RshTE8S8sNwwSUM9p1P", |
|
|
|
) |
|
|
|
|
|
|
|
def __init__(self, main_window, latest_version=None): |
|
|
|
self.main_window = main_window |
|
|
|
def __init__(self, *, latest_version=None): |
|
|
|
QDialog.__init__(self) |
|
|
|
self.setWindowTitle('Electrum - ' + _('Update Check')) |
|
|
|
self.content = QVBoxLayout() |
|
|
@ -54,7 +54,7 @@ class UpdateCheck(QDialog, Logger): |
|
|
|
|
|
|
|
self.update_view(latest_version) |
|
|
|
|
|
|
|
self.update_check_thread = UpdateCheckThread(self.main_window) |
|
|
|
self.update_check_thread = UpdateCheckThread() |
|
|
|
self.update_check_thread.checked.connect(self.on_version_retrieved) |
|
|
|
self.update_check_thread.failed.connect(self.on_retrieval_failed) |
|
|
|
self.update_check_thread.start() |
|
|
@ -97,15 +97,15 @@ class UpdateCheckThread(QThread, Logger): |
|
|
|
checked = pyqtSignal(object) |
|
|
|
failed = pyqtSignal() |
|
|
|
|
|
|
|
def __init__(self, main_window): |
|
|
|
def __init__(self): |
|
|
|
QThread.__init__(self) |
|
|
|
Logger.__init__(self) |
|
|
|
self.main_window = main_window |
|
|
|
self.network = Network.get_instance() |
|
|
|
|
|
|
|
async def get_update_info(self): |
|
|
|
# note: Use long timeout here as it is not critical that we get a response fast, |
|
|
|
# and it's bad not to get an update notification just because we did not wait enough. |
|
|
|
async with make_aiohttp_session(proxy=self.main_window.network.proxy, timeout=120) as session: |
|
|
|
async with make_aiohttp_session(proxy=self.network.proxy, timeout=120) as session: |
|
|
|
async with session.get(UpdateCheck.url) as result: |
|
|
|
signed_version_dict = await result.json(content_type=None) |
|
|
|
# example signed_version_dict: |
|
|
@ -131,12 +131,11 @@ class UpdateCheckThread(QThread, Logger): |
|
|
|
return StrictVersion(version_num.strip()) |
|
|
|
|
|
|
|
def run(self): |
|
|
|
network = self.main_window.network |
|
|
|
if not network: |
|
|
|
if not self.network: |
|
|
|
self.failed.emit() |
|
|
|
return |
|
|
|
try: |
|
|
|
update_info = asyncio.run_coroutine_threadsafe(self.get_update_info(), network.asyncio_loop).result() |
|
|
|
update_info = asyncio.run_coroutine_threadsafe(self.get_update_info(), self.network.asyncio_loop).result() |
|
|
|
except Exception as e: |
|
|
|
self.logger.info(f"got exception: '{repr(e)}'") |
|
|
|
self.failed.emit() |
|
|
|