hardware cmdline handler: print messages to stderr (take 2)
follow-up 5613f9b903
button_request should not call show_error as error dialogs in Qt block
the GUI thread.
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
from electrum.util import print_msg, print_error, raw_input
|
from electrum.util import print_error, print_stderr, raw_input
|
||||||
|
|
||||||
|
|
||||||
class CmdLineHandler:
|
class CmdLineHandler:
|
||||||
|
|
||||||
def get_passphrase(self, msg, confirm):
|
def get_passphrase(self, msg, confirm):
|
||||||
import getpass
|
import getpass
|
||||||
print_msg(msg)
|
print_stderr(msg)
|
||||||
return getpass.getpass('')
|
return getpass.getpass('')
|
||||||
|
|
||||||
def get_pin(self, msg):
|
def get_pin(self, msg):
|
||||||
t = { 'a':'7', 'b':'8', 'c':'9', 'd':'4', 'e':'5', 'f':'6', 'g':'1', 'h':'2', 'i':'3'}
|
t = { 'a':'7', 'b':'8', 'c':'9', 'd':'4', 'e':'5', 'f':'6', 'g':'1', 'h':'2', 'i':'3'}
|
||||||
print_msg(msg)
|
print_stderr(msg)
|
||||||
print_msg("a b c\nd e f\ng h i\n-----")
|
print_stderr("a b c\nd e f\ng h i\n-----")
|
||||||
o = raw_input()
|
o = raw_input()
|
||||||
try:
|
try:
|
||||||
return ''.join(map(lambda x: t[x], o))
|
return ''.join(map(lambda x: t[x], o))
|
||||||
@@ -20,24 +20,24 @@ class CmdLineHandler:
|
|||||||
|
|
||||||
def prompt_auth(self, msg):
|
def prompt_auth(self, msg):
|
||||||
import getpass
|
import getpass
|
||||||
print_msg(msg)
|
print_stderr(msg)
|
||||||
response = getpass.getpass('')
|
response = getpass.getpass('')
|
||||||
if len(response) == 0:
|
if len(response) == 0:
|
||||||
return None
|
return None
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def yes_no_question(self, msg):
|
def yes_no_question(self, msg):
|
||||||
print_msg(msg)
|
print_stderr(msg)
|
||||||
return raw_input() in 'yY'
|
return raw_input() in 'yY'
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def show_message(self, msg, on_cancel=None):
|
def show_message(self, msg, on_cancel=None):
|
||||||
print_msg(msg)
|
print_stderr(msg)
|
||||||
|
|
||||||
def show_error(self, msg, blocking=False):
|
def show_error(self, msg, blocking=False):
|
||||||
print_error(msg)
|
print_stderr(msg)
|
||||||
|
|
||||||
def update_status(self, b):
|
def update_status(self, b):
|
||||||
print_error('hw device status', b)
|
print_error('hw device status', b)
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ class TrezorClientBase(PrintError):
|
|||||||
|
|
||||||
def button_request(self, code):
|
def button_request(self, code):
|
||||||
message = self.msg or MESSAGES.get(code) or MESSAGES['default']
|
message = self.msg or MESSAGES.get(code) or MESSAGES['default']
|
||||||
self.handler.show_error(message.format(self.device), self.client.cancel)
|
self.handler.show_message(message.format(self.device), self.client.cancel)
|
||||||
|
|
||||||
def get_pin(self, code=None):
|
def get_pin(self, code=None):
|
||||||
if code == 2:
|
if code == 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user