@@ -814,7 +814,7 @@ def add_spi_flash_subparsers(
814
814
if esp is None :
815
815
raise FatalError (
816
816
"Could not connect to an Espressif device "
817
- "on any of the %d available serial ports." % len ( ser_list )
817
+ f "on any of the { len ( ser_list ) } available serial ports."
818
818
)
819
819
820
820
if esp .secure_download_mode :
@@ -1226,7 +1226,7 @@ def get_default_connected_device(
1226
1226
except (FatalError , OSError ) as err :
1227
1227
if port is not None :
1228
1228
raise
1229
- log .print (f"{ each_port } failed to connect: { err } " )
1229
+ log .error (f"{ each_port } failed to connect: { err } " )
1230
1230
if _esp and _esp ._port :
1231
1231
_esp ._port .close ()
1232
1232
_esp = None
@@ -1338,23 +1338,26 @@ def _main():
1338
1338
try :
1339
1339
main ()
1340
1340
except FatalError as e :
1341
- log .print (f"\n A fatal error occurred: { e } " )
1341
+ log .error (f"\n A fatal error occurred: { e } " )
1342
1342
sys .exit (2 )
1343
1343
except serial .serialutil .SerialException as e :
1344
- log .print (f"\n A serial exception error occurred: { e } " )
1345
- log .print (
1344
+ log .error (f"\n A serial exception error occurred: { e } " )
1345
+ log .error (
1346
1346
"Note: This error originates from pySerial. "
1347
1347
"It is likely not a problem with esptool, "
1348
1348
"but with the hardware connection or drivers."
1349
1349
)
1350
- log .print (
1350
+ log .error (
1351
1351
"For troubleshooting steps visit: "
1352
1352
"https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html"
1353
1353
)
1354
1354
sys .exit (1 )
1355
1355
except StopIteration :
1356
- log .print (traceback .format_exc ())
1357
- log .print ("A fatal error occurred: The chip stopped responding." )
1356
+ log .error (traceback .format_exc ())
1357
+ log .error ("A fatal error occurred: The chip stopped responding." )
1358
+ sys .exit (2 )
1359
+ except KeyboardInterrupt :
1360
+ log .error ("KeyboardInterrupt: Run cancelled by user." )
1358
1361
sys .exit (2 )
1359
1362
1360
1363
0 commit comments