From 08fef24e39abff0cc60f7341e7e124fccbdc5ce8 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Sat, 21 Oct 2017 21:16:22 +0300 Subject: [PATCH] gpg: use pymsgbox for PIN entrering UI --- libagent/device/trezor.py | 18 ++++++------------ setup.py | 1 + 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/libagent/device/trezor.py b/libagent/device/trezor.py index 990398d..04a33e3 100644 --- a/libagent/device/trezor.py +++ b/libagent/device/trezor.py @@ -5,6 +5,7 @@ import logging import os import sys +import pymsgbox # pylint: disable=import-error import semver from . import interface @@ -38,24 +39,17 @@ class Trezor(interface.Device): if not sys.stdin.closed and os.isatty(sys.stdin.fileno()): return conn.callback_PinMatrixRequest # CLI-based PIN handler - def qt_handler(_): - # pylint: disable=import-error - from PyQt5.QtWidgets import QApplication, QInputDialog, QLineEdit + def ui_handler(_): label = ('Use the numeric keypad to describe number positions.\n' 'The layout is:\n' ' 7 8 9\n' ' 4 5 6\n' ' 1 2 3\n' 'Please enter PIN:') - app = QApplication([]) - qd = QInputDialog() - qd.setTextEchoMode(QLineEdit.Password) - qd.setLabelText(label) - qd.show() - app.exec_() - return self._defs.PinMatrixAck(pin=qd.textValue()) - - return qt_handler + scrambled_pin = pymsgbox.password(label) + return self._defs.PinMatrixAck(pin=scrambled_pin) + + return ui_handler for d in self._defs.Transport.enumerate(): log.debug('endpoint: %s', d) diff --git a/setup.py b/setup.py index 1cb1c32..160db4a 100755 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ setup( install_requires=[ 'ecdsa>=0.13', 'ed25519>=1.4', + 'pymsgbox>=1.0.6', 'semver>=2.2', 'unidecode>=0.4.20', ],