Skip to content

Commit

Permalink
fix: remove arg --redirect-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Massimiliano-solutiontech committed Sep 6, 2023
1 parent df48429 commit d481637
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 39 deletions.
11 changes: 1 addition & 10 deletions espefuse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,6 @@ def main(custom_commandline=None, esp=None):
action="store_true",
)

init_parser.add_argument(
"--redirect-errors",
help="Redirect errors to stderr instead of stdout",
action="store_true",
default=os.environ.get("REDIRECT_ERRORS", REDIRECT_ERRORS),
)

common_args, remaining_args = init_parser.parse_known_args(custom_commandline)
debug_mode = common_args.debug or ("dump" in remaining_args)
just_print_help = [
Expand Down Expand Up @@ -270,8 +263,6 @@ def main(custom_commandline=None, esp=None):
try:
for rem_args in grouped_remaining_args:
args, unused_args = parser.parse_known_args(rem_args, namespace=common_args)
globals()["redirect_errors"] = args.redirect_errors

if args.operation is None:
parser.print_help()
parser.exit(1)
Expand Down Expand Up @@ -306,7 +297,7 @@ def _main():
except esptool.FatalError as e:
print(
"\nA fatal error occurred: %s" % e,
file=sys.stderr if globals()["redirect_errors"] else sys.stdout,
file=sys.stderr if REDIRECT_ERRORS else sys.stdout,
)
sys.exit(2)

Expand Down
12 changes: 2 additions & 10 deletions espsecure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1429,13 +1429,6 @@ def main(custom_commandline=None):
prog="espsecure",
)

parser.add_argument(
"--redirect-errors",
help="Redirect errors to stderr instead of stdout",
action="store_true",
default=os.environ.get("REDIRECT_ERRORS", REDIRECT_ERRORS),
)

subparsers = parser.add_subparsers(
dest="operation", help="Run espsecure.py {command} -h for additional help"
)
Expand Down Expand Up @@ -1798,7 +1791,6 @@ def main(custom_commandline=None):
)

args = parser.parse_args(custom_commandline)
globals()["redirect_errors"] = args.redirect_errors
print("espsecure.py v%s" % esptool.__version__)
if args.operation is None:
parser.print_help()
Expand All @@ -1821,7 +1813,7 @@ def _main():
except esptool.FatalError as e:
print(
"\nA fatal error occurred: %s" % e,
file=sys.stderr if globals()["redirect_errors"] else sys.stdout,
file=sys.stderr if REDIRECT_ERRORS else sys.stdout,
)
sys.exit(2)
except ValueError as e:
Expand All @@ -1831,7 +1823,7 @@ def _main():
"Note: This error originates from the cryptography module. "
"It is likely not a problem with espsecure, "
"please make sure you are using a compatible OpenSSL backend.",
file=sys.stderr if globals()["redirect_errors"] else sys.stdout,
file=sys.stderr if REDIRECT_ERRORS else sys.stdout,
)
finally:
raise
Expand Down
14 changes: 3 additions & 11 deletions esptool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,6 @@ def main(argv=None, esp=None):
default=os.environ.get("ESPTOOL_CONNECT_ATTEMPTS", DEFAULT_CONNECT_ATTEMPTS),
)

parser.add_argument(
"--redirect-errors",
help="Redirect errors to stderr instead of stdout",
action="store_true",
default=os.environ.get("REDIRECT_ERRORS", REDIRECT_ERRORS),
)

subparsers = parser.add_subparsers(
dest="operation", help="Run esptool.py {command} -h for additional help"
)
Expand Down Expand Up @@ -645,7 +638,6 @@ def add_spi_flash_subparsers(parent, allow_keep, auto_detect):
argv = expand_file_arguments(argv or sys.argv[1:])

args = parser.parse_args(argv)
globals()["redirect_errors"] = args.redirect_errors
print("esptool.py v%s" % __version__)
load_config_file(verbose=True)

Expand Down Expand Up @@ -1087,11 +1079,11 @@ def _main():
except FatalError as e:
print(
f"\nA fatal error occurred: {e}",
file=sys.stderr if globals()["redirect_errors"] else sys.stdout,
file=sys.stderr if REDIRECT_ERRORS else sys.stdout,
)
sys.exit(2)
except serial.serialutil.SerialException as e:
file = sys.stderr if globals()["redirect_errors"] else sys.stdout
file = sys.stderr if REDIRECT_ERRORS else sys.stdout
print(f"\nA serial exception error occurred: {e}", file=file)
print(
"Note: This error originates from pySerial. "
Expand All @@ -1106,7 +1098,7 @@ def _main():
)
sys.exit(1)
except StopIteration:
file = sys.stderr if globals()["redirect_errors"] else sys.stdout
file = sys.stderr if REDIRECT_ERRORS else sys.stdout
print(traceback.format_exc(), file=file)
print("A fatal error occurred: The chip stopped responding.", file=file)
sys.exit(2)
Expand Down
9 changes: 1 addition & 8 deletions flasher_stub/wrap_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def wrap_stub(elf_file):
stub.get("data_start", 0),
stub["entry"],
),
file=sys.stderr if globals()["redirect_errors"] else sys.stdout,
file=sys.stderr if REDIRECT_ERRORS else sys.stdout,
)

return stub
Expand All @@ -80,14 +80,7 @@ def stub_name(filename):
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("elf_files", nargs="+", help="Stub ELF files to convert")
parser.add_argument(
"--redirect-errors",
help="Redirect errors to stderr instead of stdout",
action="store_true",
default=os.environ.get("REDIRECT_ERRORS", REDIRECT_ERRORS),
)
args = parser.parse_args()
globals()["redirect_errors"] = args.redirect_errors

stubs = dict(
(stub_name(elf_file), wrap_stub(elf_file)) for elf_file in args.elf_files
Expand Down

0 comments on commit d481637

Please sign in to comment.