@@ -189,7 +189,9 @@ def authenticate(remote_addr, remote_port, password, md5_target, filename, conte
189
189
return False , str (e )
190
190
191
191
192
- def serve (remote_addr , local_addr , remote_port , local_port , password , md5_target , filename , command = FLASH ): # noqa: C901
192
+ def serve (
193
+ remote_addr , local_addr , remote_port , local_port , password , md5_target , filename , command = FLASH
194
+ ): # noqa: C901
193
195
# Create a TCP/IP socket
194
196
sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
195
197
server_address = (local_addr , local_port )
@@ -220,7 +222,9 @@ def serve(remote_addr, local_addr, remote_port, local_port, password, md5_target
220
222
# Try authentication with the specified method first
221
223
sys .stderr .write ("Authenticating..." )
222
224
sys .stderr .flush ()
223
- auth_success , auth_error = authenticate (remote_addr , remote_port , password , md5_target , filename , content_size , file_md5 , nonce )
225
+ auth_success , auth_error = authenticate (
226
+ remote_addr , remote_port , password , md5_target , filename , content_size , file_md5 , nonce
227
+ )
224
228
225
229
if not auth_success :
226
230
# If authentication failed and we're not already using MD5, try with MD5
@@ -229,7 +233,9 @@ def serve(remote_addr, local_addr, remote_port, local_port, password, md5_target
229
233
logging .warning ("Authentication failed with SHA256, retrying with MD5: %s" , auth_error )
230
234
231
235
# Restart the entire process with MD5 to get a fresh nonce
232
- success , data , error = send_invitation_and_get_auth_challenge (remote_addr , remote_port , message , True )
236
+ success , data , error = send_invitation_and_get_auth_challenge (
237
+ remote_addr , remote_port , message , True
238
+ )
233
239
if not success :
234
240
logging .error ("Failed to re-establish connection for MD5 retry: %s" , error )
235
241
return 1
@@ -238,7 +244,9 @@ def serve(remote_addr, local_addr, remote_port, local_port, password, md5_target
238
244
nonce = data .split ()[1 ]
239
245
sys .stderr .write ("Retrying with MD5..." )
240
246
sys .stderr .flush ()
241
- auth_success , auth_error = authenticate (remote_addr , remote_port , password , True , filename , content_size , file_md5 , nonce )
247
+ auth_success , auth_error = authenticate (
248
+ remote_addr , remote_port , password , True , filename , content_size , file_md5 , nonce
249
+ )
242
250
else :
243
251
auth_success = False
244
252
auth_error = "Expected AUTH challenge for MD5 retry, got: " + data
@@ -331,7 +339,9 @@ def serve(remote_addr, local_addr, remote_port, local_port, password, md5_target
331
339
332
340
# After all attempts, provide detailed error information
333
341
if received_any_response :
334
- logging .warning ("Upload completed but device sent unexpected response(s). This may still be successful." )
342
+ logging .warning (
343
+ "Upload completed but device sent unexpected response(s). This may still be successful."
344
+ )
335
345
logging .warning ("Device might be rebooting to apply firmware - this is normal." )
336
346
connection .close ()
337
347
return 0 # Consider it successful if we got any response and upload completed
@@ -448,7 +458,7 @@ def main(args):
448
458
options .auth ,
449
459
options .md5_target ,
450
460
options .image ,
451
- command
461
+ command ,
452
462
)
453
463
454
464
0 commit comments