Skip to content

Commit d8ae230

Browse files
committed
fix: stop exit 0 when being called programmatically
1 parent 8e2b94e commit d8ae230

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

espefuse/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ def main(argv: list[str] | None = None, esp: esptool.ESPLoader | None = None):
214214
returned by esptool.get_default_connected_device()
215215
"""
216216
args = esptool.expand_file_arguments(argv or sys.argv[1:])
217-
cli(args=args, esp=esp)
217+
try:
218+
cli(args=args, esp=esp)
219+
except SystemExit as e:
220+
if e.code != 0:
221+
raise
218222

219223

220224
def _main():

espsecure/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1957,7 +1957,11 @@ def main(argv: list[str] | None = None):
19571957
Arguments and their values need to be added as individual items to the list
19581958
e.g. "--port /dev/ttyUSB1" thus becomes ['--port', '/dev/ttyUSB1'].
19591959
"""
1960-
cli(args=argv)
1960+
try:
1961+
cli(args=argv)
1962+
except SystemExit as e:
1963+
if e.code != 0:
1964+
raise
19611965

19621966

19631967
def _main():

esptool/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,11 @@ def main(argv: list[str] | None = None, esp: ESPLoader | None = None):
10281028
returned by get_default_connected_device()
10291029
"""
10301030
args = expand_file_arguments(argv or sys.argv[1:])
1031-
cli(args=args, esp=esp)
1031+
try:
1032+
cli(args=args, esp=esp)
1033+
except SystemExit as e:
1034+
if e.code != 0:
1035+
raise
10321036

10331037

10341038
def get_port_list(

0 commit comments

Comments
 (0)