Skip to content

Commit

Permalink
kivy: fix crash in logging.py; platform.platform() not available
Browse files Browse the repository at this point in the history
  • Loading branch information
SomberNight committed May 6, 2019
1 parent 8e32f49 commit 7a99fdc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 2 additions & 4 deletions electrum/base_crash_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from . import constants
from .i18n import _
from .util import make_aiohttp_session
from .logging import describe_os_version


class BaseCrashReporter:
Expand Down Expand Up @@ -95,7 +96,7 @@ def get_additional_info(self):
args = {
"app_version": ELECTRUM_VERSION,
"python_version": sys.version,
"os": self.get_os_version(),
"os": describe_os_version(),
"wallet_type": "unknown",
"locale": locale.getdefaultlocale()[0] or "?",
"description": self.get_user_description()
Expand Down Expand Up @@ -129,6 +130,3 @@ def get_user_description(self):

def get_wallet_type(self):
raise NotImplementedError

def get_os_version(self):
raise NotImplementedError
8 changes: 0 additions & 8 deletions electrum/gui/kivy/uix/dialogs/crash_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,6 @@ def get_user_description(self):
def get_wallet_type(self):
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):
def __init__(self, text):
Expand Down
3 changes: 0 additions & 3 deletions electrum/gui/qt/exception_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ def get_user_description(self):
def get_wallet_type(self):
return self.main_window.wallet.wallet_type

def get_os_version(self):
return platform.platform()


def _show_window(*args):
if not Exception_Window._active_window:
Expand Down
15 changes: 14 additions & 1 deletion electrum/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,22 @@ def configure_logging(config):

from . import ELECTRUM_VERSION
_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)}")


def get_logfile_path() -> Optional[pathlib.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()

0 comments on commit 7a99fdc

Please sign in to comment.