Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c8cb57f

Browse files
author
a
committed
cleaning
1 parent f81bac8 commit c8cb57f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

‎xxh/xxh_xxh/xxh.py‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def pssh(self, cmd, accept_host=None, host_password=None, key_password=None):
131131
if self.vverbose:
132132
self.eprint(f'Pexpect caught pattern: {patterns[pattern]}')
133133

134-
if pattern in [0,1]:
134+
if pattern in [0, 1]:
135135
# Expected:
136136
# The authenticity of host '<...>' can't be established.
137137
# ECDSA key fingerprint is <...>
@@ -154,13 +154,15 @@ def pssh(self, cmd, accept_host=None, host_password=None, key_password=None):
154154
if pattern == 2:
155155
# Expected:
156156
# Enter passphrase for key '<keyfile>':
157-
if key_password is None:
158-
user_key_password = getpass.getpass(prompt=(sess.before + sess.after).decode("utf-8")+' ')
157+
if user_key_password:
159158
sess.sendline(user_key_password)
160-
else:
159+
elif key_password:
161160
sess.sendline(key_password)
161+
else:
162+
user_key_password = getpass.getpass(prompt=(sess.before + sess.after).decode("utf-8")+' ')
163+
sess.sendline(user_key_password)
162164

163-
if pattern in [3,4]:
165+
if pattern in [3, 4]:
164166
# Expected:
165167
# <host>`s password:
166168
if host_password is None:
@@ -177,22 +179,22 @@ def pssh(self, cmd, accept_host=None, host_password=None, key_password=None):
177179
output = output[3:] if output.startswith(' \r\n') else output
178180
result = {
179181
'user_host_accept': user_host_accept,
180-
'user_host_password':user_host_password,
181-
'user_key_password':user_key_password,
182+
'user_host_password': user_host_password,
183+
'user_key_password': user_key_password,
182184
'output':output
183185
}
184186

185187
return result
186188

187-
if pattern in [6,7]:
189+
if pattern in [6, 7]:
188190
# Prompt
189191
print(sess.before.decode("utf-8"))
190192
sess.interact()
191193

192194
result = {
193195
'user_host_accept': user_host_accept,
194-
'user_host_password':user_host_password,
195-
'user_key_password':user_key_password
196+
'user_host_password': user_host_password,
197+
'user_key_password': user_key_password
196198
}
197199
return result
198200

0 commit comments

Comments
 (0)