electrum

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

commit d4de25a8cde35ee47a7594194eef794a1b4f7b2b
parent 6620974f3deea4e3d3f42a63eccd30192e41b89c
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed, 10 Mar 2021 16:23:49 +0100

crash reports: fix get_git_version for kivy

Diffstat:
Melectrum/base_crash_reporter.py | 18++----------------
Melectrum/logging.py | 12++++++++++++
2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/electrum/base_crash_reporter.py b/electrum/base_crash_reporter.py @@ -23,15 +23,13 @@ import asyncio import json import locale import traceback -import subprocess import sys -import os from .version import ELECTRUM_VERSION from . import constants from .i18n import _ from .util import make_aiohttp_session -from .logging import describe_os_version, Logger +from .logging import describe_os_version, Logger, get_git_version class BaseCrashReporter(Logger): @@ -95,7 +93,7 @@ class BaseCrashReporter(Logger): def get_additional_info(self): args = { - "app_version": ELECTRUM_VERSION, + "app_version": get_git_version() or ELECTRUM_VERSION, "python_version": sys.version, "os": describe_os_version(), "wallet_type": "unknown", @@ -107,20 +105,8 @@ class BaseCrashReporter(Logger): except: # Maybe the wallet isn't loaded yet pass - try: - args["app_version"] = self.get_git_version() - except: - # This is probably not running from source - pass return args - @staticmethod - def get_git_version(): - dir = os.path.dirname(os.path.realpath(sys.argv[0])) - version = subprocess.check_output( - ['git', 'describe', '--always', '--dirty'], cwd=dir) - return str(version, "utf8").strip() - def _get_traceback_str(self) -> str: return "".join(traceback.format_exception(*self.exc_args)) diff --git a/electrum/logging.py b/electrum/logging.py @@ -10,6 +10,7 @@ import os import platform from typing import Optional import copy +import subprocess class LogFormatterForFiles(logging.Formatter): @@ -268,3 +269,14 @@ def describe_os_version() -> str: return "Android {} on {} {} ({})".format(bv.RELEASE, b.BRAND, b.DEVICE, b.DISPLAY) else: return platform.platform() + + +def get_git_version() -> Optional[str]: + dir = os.path.dirname(os.path.realpath(__file__)) + try: + version = subprocess.check_output( + ['git', 'describe', '--always', '--dirty'], cwd=dir) + version = str(version, "utf8").strip() + except Exception: + version = None + return version