1
0

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"
}
```
This commit is contained in:
SomberNight
2022-04-11 17:05:26 +02:00
parent 419fc6e1c1
commit e47e0afa91
8 changed files with 122 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ import os
import sys
import hashlib
import hmac
from typing import Union
from typing import Union, Mapping, Optional
from .util import assert_bytes, InvalidPassword, to_bytes, to_string, WalletFileException, versiontuple
from .i18n import _
@@ -84,6 +84,27 @@ if not (HAS_CRYPTODOME or HAS_CRYPTOGRAPHY):
sys.exit(f"Error: at least one of ('pycryptodomex', 'cryptography') needs to be installed.")
def version_info() -> Mapping[str, Optional[str]]:
ret = {}
if HAS_PYAES:
ret["pyaes.version"] = ".".join(map(str, pyaes.VERSION[:3]))
else:
ret["pyaes.version"] = None
if HAS_CRYPTODOME:
ret["cryptodome.version"] = Cryptodome.__version__
if hasattr(Cryptodome, "__path__"):
ret["cryptodome.path"] = ", ".join(Cryptodome.__path__ or [])
else:
ret["cryptodome.version"] = None
if HAS_CRYPTOGRAPHY:
ret["cryptography.version"] = cryptography.__version__
if hasattr(cryptography, "__path__"):
ret["cryptography.path"] = ", ".join(cryptography.__path__ or [])
else:
ret["cryptography.version"] = None
return ret
class InvalidPadding(Exception):
pass