1
0
Files
electrum/electrum/gui/kivy/__init__.py
SomberNight e47e0afa91 commands: add "version_info" cmd
example:
```
$ ./run_electrum -o version_info
{
    "aiohttp.version": "3.8.1",
    "aiorpcx.version": "0.22.1",
    "certifi.version": "2021.10.08",
    "cryptodome.version": null,
    "cryptography.path": "/home/user/.local/lib/python3.8/site-packages/cryptography",
    "cryptography.version": "3.4.6",
    "dnspython.version": "2.2.0",
    "electrum.path": "/home/user/wspace/electrum/electrum",
    "electrum.version": "4.2.1",
    "hidapi.version": "0.11.0.post2",
    "libsecp256k1.path": "/home/user/wspace/electrum/electrum/libsecp256k1.so.0",
    "libusb.path": "libusb-1.0.so",
    "libusb.version": "1.0.23.11397",
    "libzbar.path": "/home/user/wspace/electrum/electrum/libzbar.so.0",
    "pyaes.version": "1.3.0",
    "pyqt.path": "/usr/lib/python3/dist-packages/PyQt5",
    "pyqt.version": "5.14.1",
    "qt.version": "5.12.8"
}
```
2022-04-11 17:40:22 +02:00

92 lines
3.0 KiB
Python

#!/usr/bin/env python
#
# Electrum - lightweight Bitcoin client
# Copyright (C) 2012 thomasv@gitorious
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Kivy GUI
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 as e:
# This error ideally shouldn't be raised with pre-built packages
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')
from electrum.logging import Logger
from electrum.gui import BaseElectrumGui
if TYPE_CHECKING:
from electrum.simple_config import SimpleConfig
from electrum.daemon import Daemon
from electrum.plugin import Plugins
class ElectrumGui(BaseElectrumGui, Logger):
def __init__(self, *, config: 'SimpleConfig', daemon: 'Daemon', plugins: 'Plugins'):
BaseElectrumGui.__init__(self, config=config, daemon=daemon, plugins=plugins)
Logger.__init__(self)
self.logger.debug('ElectrumGUI: initialising')
self.network = daemon.network
def main(self):
from .main_window import ElectrumWindow
w = ElectrumWindow(
config=self.config,
network=self.network,
plugins=self.plugins,
gui_object=self,
)
w.run()
def stop(self) -> None:
from kivy.app import App
from kivy.clock import Clock
app = App.get_running_app()
if not app:
return
Clock.schedule_once(lambda dt: app.stop())
@classmethod
def version_info(cls):
ret = {
"kivy.version": kivy.__version__,
}
if hasattr(kivy, "__path__"):
ret["kivy.path"] = ", ".join(kivy.__path__ or [])
return ret