Browse Source

crash reports: fix get_git_version for kivy

patch-4
SomberNight 4 years ago
parent
commit
d4de25a8cd
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 18
      electrum/base_crash_reporter.py
  2. 12
      electrum/logging.py

18
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))

12
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

Loading…
Cancel
Save