1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 13:38:12 +00:00

src/apps/debug: use big if __debug__ block

This commit is contained in:
Pavol Rusnak 2018-06-06 00:37:20 +02:00
parent 9e16eb4122
commit 290643782a
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -1,42 +1,41 @@
from trezor import loop, utils
from trezor.messages import wire_types
from trezor.messages.DebugLinkState import DebugLinkState
from trezor.ui import confirm, swipe
from trezor.wire import register, protobuf_workflow
from apps.common import storage
if not __debug__:
utils.halt("debug mode inactive")
from trezor.utils import halt
halt("debug mode inactive")
reset_internal_entropy = None
reset_current_words = None
reset_word_index = None
if __debug__:
from trezor import loop
from trezor.messages import wire_types
from trezor.messages.DebugLinkState import DebugLinkState
from trezor.ui import confirm, swipe
from trezor.wire import register, protobuf_workflow
from apps.common import storage
confirm_signal = loop.signal()
swipe_signal = loop.signal()
input_signal = loop.signal()
reset_internal_entropy = None
reset_current_words = None
reset_word_index = None
confirm_signal = loop.signal()
swipe_signal = loop.signal()
input_signal = loop.signal()
async def dispatch_DebugLinkDecision(ctx, msg):
if msg.yes_no is not None:
confirm_signal.send(confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED)
if msg.up_down is not None:
swipe_signal.send(swipe.SWIPE_DOWN if msg.up_down else swipe.SWIPE_UP)
if msg.input is not None:
input_signal.send(msg.input)
async def dispatch_DebugLinkDecision(ctx, msg):
if msg.yes_no is not None:
confirm_signal.send(confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED)
if msg.up_down is not None:
swipe_signal.send(swipe.SWIPE_DOWN if msg.up_down else swipe.SWIPE_UP)
if msg.input is not None:
input_signal.send(msg.input)
async def dispatch_DebugLinkGetState(ctx, msg):
m = DebugLinkState()
m.mnemonic = storage.get_mnemonic()
m.passphrase_protection = storage.has_passphrase()
m.reset_word_pos = reset_word_index
m.reset_entropy = reset_internal_entropy
if reset_current_words:
m.reset_word = ' '.join(reset_current_words)
return m
async def dispatch_DebugLinkGetState(ctx, msg):
m = DebugLinkState()
m.mnemonic = storage.get_mnemonic()
m.passphrase_protection = storage.has_passphrase()
m.reset_word_pos = reset_word_index
m.reset_entropy = reset_internal_entropy
if reset_current_words:
m.reset_word = ' '.join(reset_current_words)
return m
def boot():
register(wire_types.DebugLinkDecision, protobuf_workflow, dispatch_DebugLinkDecision)
register(wire_types.DebugLinkGetState, protobuf_workflow, dispatch_DebugLinkGetState)
def boot():
register(wire_types.DebugLinkDecision, protobuf_workflow, dispatch_DebugLinkDecision)
register(wire_types.DebugLinkGetState, protobuf_workflow, dispatch_DebugLinkGetState)