From c8cb57f9d667b7ed5bb4bbc8edf54320b2663278 Mon Sep 17 00:00:00 2001 From: a Date: Thu, 1 Apr 2021 08:44:48 +0300 Subject: [PATCH] cleaning --- xxh/xxh_xxh/xxh.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/xxh/xxh_xxh/xxh.py b/xxh/xxh_xxh/xxh.py index 27063cd..c75996b 100644 --- a/xxh/xxh_xxh/xxh.py +++ b/xxh/xxh_xxh/xxh.py @@ -131,7 +131,7 @@ class xxh: if self.vverbose: self.eprint(f'Pexpect caught pattern: {patterns[pattern]}') - if pattern in [0,1]: + if pattern in [0, 1]: # Expected: # The authenticity of host '<...>' can't be established. # ECDSA key fingerprint is <...> @@ -154,13 +154,15 @@ class xxh: if pattern == 2: # Expected: # Enter passphrase for key '': - if key_password is None: + if user_key_password: + sess.sendline(user_key_password) + elif key_password: + sess.sendline(key_password) + else: user_key_password = getpass.getpass(prompt=(sess.before + sess.after).decode("utf-8")+' ') sess.sendline(user_key_password) - else: - sess.sendline(key_password) - if pattern in [3,4]: + if pattern in [3, 4]: # Expected: # `s password: if host_password is None: @@ -177,22 +179,22 @@ class xxh: output = output[3:] if output.startswith(' \r\n') else output result = { 'user_host_accept': user_host_accept, - 'user_host_password':user_host_password, - 'user_key_password':user_key_password, + 'user_host_password': user_host_password, + 'user_key_password': user_key_password, 'output':output } return result - if pattern in [6,7]: + if pattern in [6, 7]: # Prompt print(sess.before.decode("utf-8")) sess.interact() result = { 'user_host_accept': user_host_accept, - 'user_host_password':user_host_password, - 'user_key_password':user_key_password + 'user_host_password': user_host_password, + 'user_key_password': user_key_password } return result