From e10b42bbb56df7cf7ca8a27c9ab4d0bf37bb1c0d Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Sun, 6 Mar 2016 21:59:17 +0200 Subject: [PATCH] client: catch CallException for cancellation handling --- trezor_agent/client.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/trezor_agent/client.py b/trezor_agent/client.py index e009f7f..562f7ce 100644 --- a/trezor_agent/client.py +++ b/trezor_agent/client.py @@ -23,6 +23,7 @@ class Client(object): self.client = client_wrapper.connection self.identity_type = client_wrapper.identity_type self.device_name = client_wrapper.device_name + self.call_exception = client_wrapper.call_exception self.curve = curve def __enter__(self): @@ -72,10 +73,15 @@ class Client(object): log.info('please confirm user "%s" login to "%s" using %s...', msg['user'], label, self.device_name) - result = self.client.sign_identity(identity=identity, - challenge_hidden=blob, - challenge_visual=visual, - ecdsa_curve_name=self.curve) + try: + result = self.client.sign_identity(identity=identity, + challenge_hidden=blob, + challenge_visual=visual, + ecdsa_curve_name=self.curve) + except self.call_exception as e: + code, msg = e.args + log.warning('%s error #%s: %s', self.device_name, code, msg) + raise IOError(msg) verifying_key = formats.decompress_pubkey(pubkey=result.public_key, curve_name=self.curve)