def cancel_hw_operation(hw_client): try: hw_type = get_hw_type(hw_client) if hw_type in (HWType.trezor, HWType.keepkey): hw_client.cancel() except Exception as e: logging.error('Error when cancelling hw operation: %s', str(e))
def get_hw_label(hw_client): hw_type = get_hw_type(hw_client) if hw_type == HWType.trezor: return 'Trezor (' + hw_client.features.label + ')' elif hw_type == HWType.keepkey: return 'KeepKey (' + hw_client.features.label + ')' elif hw_type == HWType.ledger_nano_s: return 'Ledger Nano S'
def disconnect_hw(hw_client): try: hw_type = get_hw_type(hw_client) if hw_type in (HWType.trezor, HWType.keepkey): hw_client.close() elif hw_type == HWType.ledger_nano_s: hw_client.dongle.close() except Exception as e: # probably already disconnected logging.exception('Disconnect HW error')
def get_hw_firmware_version(hw_session: HwSessionInfo): hw_type = get_hw_type(hw_session.hw_client) if hw_type in (HWType.trezor, HWType.keepkey): return str(hw_session.hw_client.features.major_version) + '.' + \ str(hw_session.hw_client.features.minor_version) + '.' + \ str(hw_session.hw_client.features.patch_version) elif hw_type == HWType.ledger_nano_s: return hw_session.hw_client.getFirmwareVersion().get('version')
def cancel_hw_thread_dialog(hw_client): try: hw_type = get_hw_type(hw_client) if hw_type == HWType.trezor: hw_client.cancel() elif hw_type == HWType.keepkey: hw_client.cancel() elif hw_type == HWType.ledger_nano_s: return False raise CancelException('Cancel') except CancelException: raise except Exception as e: logging.warning('Error when canceling hw session. Details: %s', str(e)) return True
def get_hw_label(hw_client): hw_type = get_hw_type(hw_client) if hw_type in (HWType.trezor, HWType.keepkey): return hw_client.features.label elif hw_type == HWType.ledger_nano_s: return 'Ledger Nano S'
def cancel_hw_operation(hw_client): hw_type = get_hw_type(hw_client) if hw_type in (HWType.trezor, HWType.keepkey): hw_client.cancel()