Browse Source
gui init: raise GuiImportError instead of sys.exit if dep is missing
patch-4
SomberNight
3 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
4 changed files with
20 additions and
6 deletions
-
electrum/__init__.py
-
electrum/daemon.py
-
electrum/gui/kivy/__init__.py
-
electrum/gui/qt/__init__.py
|
|
@ -11,6 +11,10 @@ if is_local and os.name == 'nt': |
|
|
|
os.add_dll_directory(os.path.dirname(__file__)) |
|
|
|
|
|
|
|
|
|
|
|
class GuiImportError(ImportError): |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
from .version import ELECTRUM_VERSION |
|
|
|
from .util import format_satoshis |
|
|
|
from .wallet import Wallet |
|
|
|
|
|
@ -51,6 +51,7 @@ from .commands import known_commands, Commands |
|
|
|
from .simple_config import SimpleConfig |
|
|
|
from .exchange_rate import FxThread |
|
|
|
from .logging import get_logger, Logger |
|
|
|
from . import GuiImportError |
|
|
|
|
|
|
|
if TYPE_CHECKING: |
|
|
|
from electrum import gui |
|
|
@ -621,8 +622,11 @@ class Daemon(Logger): |
|
|
|
if gui_name in ['lite', 'classic']: |
|
|
|
gui_name = 'qt' |
|
|
|
self.logger.info(f'launching GUI: {gui_name}') |
|
|
|
try: |
|
|
|
try: |
|
|
|
gui = __import__('electrum.gui.' + gui_name, fromlist=['electrum']) |
|
|
|
except GuiImportError as e: |
|
|
|
sys.exit(str(e)) |
|
|
|
self.gui_object = gui.ElectrumGui(config=config, daemon=self, plugins=plugins) |
|
|
|
if not self._stop_entered: |
|
|
|
self.gui_object.main() |
|
|
|
|
|
@ -29,16 +29,19 @@ import sys |
|
|
|
import os |
|
|
|
from typing import TYPE_CHECKING |
|
|
|
|
|
|
|
from electrum import GuiImportError |
|
|
|
|
|
|
|
KIVY_GUI_PATH = os.path.abspath(os.path.dirname(__file__)) |
|
|
|
os.environ['KIVY_DATA_DIR'] = os.path.join(KIVY_GUI_PATH, 'data') |
|
|
|
|
|
|
|
try: |
|
|
|
sys.argv = [''] |
|
|
|
import kivy |
|
|
|
except ImportError: |
|
|
|
except ImportError as e: |
|
|
|
# This error ideally shouldn't be raised with pre-built packages |
|
|
|
sys.exit("Error: Could not import kivy. Please install it using the " |
|
|
|
"instructions mentioned here `https://kivy.org/#download` .") |
|
|
|
raise GuiImportError( |
|
|
|
"Error: Could not import kivy. Please install it using the " |
|
|
|
"instructions mentioned here `https://kivy.org/#download` .") from e |
|
|
|
|
|
|
|
# minimum required version for kivy |
|
|
|
kivy.require('1.8.0') |
|
|
|
|
|
@ -30,12 +30,15 @@ import traceback |
|
|
|
import threading |
|
|
|
from typing import Optional, TYPE_CHECKING, List |
|
|
|
|
|
|
|
from electrum import GuiImportError |
|
|
|
|
|
|
|
try: |
|
|
|
import PyQt5 |
|
|
|
import PyQt5.QtGui |
|
|
|
except Exception: |
|
|
|
sys.exit("Error: Could not import PyQt5 on Linux systems, you may try 'sudo apt-get install python3-pyqt5'") |
|
|
|
except Exception as e: |
|
|
|
raise GuiImportError( |
|
|
|
"Error: Could not import PyQt5 on Linux systems, " |
|
|
|
"you may try 'sudo apt-get install python3-pyqt5'") from e |
|
|
|
|
|
|
|
from PyQt5.QtGui import QGuiApplication |
|
|
|
from PyQt5.QtWidgets import (QApplication, QSystemTrayIcon, QWidget, QMenu, |
|
|
|