Browse Source

kivy: fix crash in logging.py; platform.platform() not available

regtest_lnd
SomberNight 6 years ago
parent
commit
7a99fdc275
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 6
      electrum/base_crash_reporter.py
  2. 8
      electrum/gui/kivy/uix/dialogs/crash_reporter.py
  3. 3
      electrum/gui/qt/exception_window.py
  4. 15
      electrum/logging.py

6
electrum/base_crash_reporter.py

@ -31,6 +31,7 @@ from .version import ELECTRUM_VERSION
from . import constants from . import constants
from .i18n import _ from .i18n import _
from .util import make_aiohttp_session from .util import make_aiohttp_session
from .logging import describe_os_version
class BaseCrashReporter: class BaseCrashReporter:
@ -95,7 +96,7 @@ class BaseCrashReporter:
args = { args = {
"app_version": ELECTRUM_VERSION, "app_version": ELECTRUM_VERSION,
"python_version": sys.version, "python_version": sys.version,
"os": self.get_os_version(), "os": describe_os_version(),
"wallet_type": "unknown", "wallet_type": "unknown",
"locale": locale.getdefaultlocale()[0] or "?", "locale": locale.getdefaultlocale()[0] or "?",
"description": self.get_user_description() "description": self.get_user_description()
@ -129,6 +130,3 @@ class BaseCrashReporter:
def get_wallet_type(self): def get_wallet_type(self):
raise NotImplementedError raise NotImplementedError
def get_os_version(self):
raise NotImplementedError

8
electrum/gui/kivy/uix/dialogs/crash_reporter.py

@ -156,14 +156,6 @@ class CrashReporter(BaseCrashReporter, Factory.Popup):
def get_wallet_type(self): def get_wallet_type(self):
return self.main_window.wallet.wallet_type return self.main_window.wallet.wallet_type
def get_os_version(self):
if utils.platform is not "android":
return utils.platform
import jnius
bv = jnius.autoclass('android.os.Build$VERSION')
b = jnius.autoclass('android.os.Build')
return "Android {} on {} {} ({})".format(bv.RELEASE, b.BRAND, b.DEVICE, b.DISPLAY)
class CrashReportDetails(Factory.Popup): class CrashReportDetails(Factory.Popup):
def __init__(self, text): def __init__(self, text):

3
electrum/gui/qt/exception_window.py

@ -124,9 +124,6 @@ class Exception_Window(BaseCrashReporter, QWidget, MessageBoxMixin, Logger):
def get_wallet_type(self): def get_wallet_type(self):
return self.main_window.wallet.wallet_type return self.main_window.wallet.wallet_type
def get_os_version(self):
return platform.platform()
def _show_window(*args): def _show_window(*args):
if not Exception_Window._active_window: if not Exception_Window._active_window:

15
electrum/logging.py

@ -167,9 +167,22 @@ def configure_logging(config):
from . import ELECTRUM_VERSION from . import ELECTRUM_VERSION
_logger.info(f"Electrum version: {ELECTRUM_VERSION} - https://electrum.org - https://github.com/spesmilo/electrum") _logger.info(f"Electrum version: {ELECTRUM_VERSION} - https://electrum.org - https://github.com/spesmilo/electrum")
_logger.info(f"Python version: {sys.version}. On platform: {platform.platform()}") _logger.info(f"Python version: {sys.version}. On platform: {describe_os_version()}")
_logger.info(f"Logging to file: {str(_logfile_path)}") _logger.info(f"Logging to file: {str(_logfile_path)}")
def get_logfile_path() -> Optional[pathlib.Path]: def get_logfile_path() -> Optional[pathlib.Path]:
return _logfile_path return _logfile_path
def describe_os_version() -> str:
if 'ANDROID_DATA' in os.environ:
from kivy import utils
if utils.platform is not "android":
return utils.platform
import jnius
bv = jnius.autoclass('android.os.Build$VERSION')
b = jnius.autoclass('android.os.Build')
return "Android {} on {} {} ({})".format(bv.RELEASE, b.BRAND, b.DEVICE, b.DISPLAY)
else:
return platform.platform()

Loading…
Cancel
Save