From 41ccd2f332c40e498ed10c85065913f745343fbe Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Fri, 22 Dec 2017 17:10:27 +0200 Subject: [PATCH] fix new pylint warning --- libagent/device/trezor.py | 5 ++--- libagent/formats.py | 4 ++++ libagent/ssh/__init__.py | 1 + libagent/tests/test_server.py | 6 +++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libagent/device/trezor.py b/libagent/device/trezor.py index 0e67ea8..e72390a 100644 --- a/libagent/device/trezor.py +++ b/libagent/device/trezor.py @@ -21,11 +21,10 @@ def _message_box(label, sp=subprocess): p = sp.Popen(args=args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) out, err = p.communicate(label.encode('ascii')) exitcode = p.wait() - if exitcode == 0: - return out.decode('ascii') - else: + if exitcode != 0: log.error('UI failed: %r', err) raise sp.CalledProcessError(exitcode, args) + return out.decode('ascii') def _is_open_tty(stream): diff --git a/libagent/formats.py b/libagent/formats.py index 939311b..468da74 100644 --- a/libagent/formats.py +++ b/libagent/formats.py @@ -102,6 +102,8 @@ def _decompress_ed25519(pubkey): if pubkey[:1] == b'\x00': # set by Trezor fsm_msgSignIdentity() and fsm_msgGetPublicKey() return ed25519.VerifyingKey(pubkey[1:]) + else: + return None def _decompress_nist256(pubkey): @@ -126,6 +128,8 @@ def _decompress_nist256(pubkey): point = ecdsa.ellipticcurve.Point(curve.curve, x, y) return ecdsa.VerifyingKey.from_public_point(point, curve=curve, hashfunc=hashfunc) + else: + return None def decompress_pubkey(pubkey, curve_name): diff --git a/libagent/ssh/__init__.py b/libagent/ssh/__init__.py index c01364e..e5dc38d 100644 --- a/libagent/ssh/__init__.py +++ b/libagent/ssh/__init__.py @@ -228,3 +228,4 @@ def main(device_type): else: for pk in conn.public_keys(): sys.stdout.write(pk) + return 0 # success exit code diff --git a/libagent/tests/test_server.py b/libagent/tests/test_server.py index 4c010a9..33981fe 100644 --- a/libagent/tests/test_server.py +++ b/libagent/tests/test_server.py @@ -79,9 +79,9 @@ def test_server_thread(): class FakeServer(object): def accept(self): # pylint: disable=no-self-use - if connections: - return connections.pop(), 'address' - raise socket.timeout() + if not connections: + raise socket.timeout() + return connections.pop(), 'address' def getsockname(self): # pylint: disable=no-self-use return 'fake_server'