pin: use PyQt only when running with no TTY

This commit is contained in:
Roman Zeyde 2017-05-21 21:03:04 +03:00
parent 69c54eb425
commit f6911a0016
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -3,6 +3,7 @@
import binascii
import logging
import os
import sys
import semver
@ -34,12 +35,12 @@ class Trezor(interface.Device):
return self._defs.PassphraseAck(passphrase=self.passphrase)
def create_pin_handler(conn):
try:
from PyQt5.QtWidgets import QApplication, QInputDialog, QLineEdit
except ImportError:
if 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
label = ('Use the numeric keypad to describe number positions.\n'
'The layout is:\n'
' 7 8 9\n'