tools: print tracebacks to the same stream as delimiters

Error output is currently a garbled mess, delimiters are printed with
poutput() or print(), traceback with traceback.print_exc() which goes
to stderr.

Reading stdout alone omits the report but not -->8-- lines.
Reading both streams makes the traceback appear where the two buffers
just happen to interleave, stderr is usually unbuffered but stdout is
not, so I get the error trace, APDU trace, then empty -->8-- lines.

Fix this by aligning the printing funcs.

Change-Id: I2ed37dfe241d014e4a26894cddbc9b21be1fd0c2
This commit is contained in:
Eric Wild
2026-09-23 17:51:04 +02:00
parent a0e14a16f2
commit ff3f275c84
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -816,7 +816,7 @@ if __name__ == '__main__':
print("")
print("Card programming failed with an exception:")
print("---------------------8<---------------------")
traceback.print_exc()
print(traceback.format_exc().rstrip())
print("---------------------8<---------------------")
print("")
rc = -1
+3 -3
View File
@@ -351,7 +351,7 @@ Online manual available at https://downloads.osmocom.org/docs/pysim/master/html/
self.poutput("")
self.poutput("Card initialization (%s) failed with an exception:" % str(self.sl))
self.poutput("---------------------8<---------------------")
traceback.print_exc()
self.poutput(traceback.format_exc().rstrip())
self.poutput("---------------------8<---------------------")
self.poutput("")
return -1
@@ -465,7 +465,7 @@ Online manual available at https://downloads.osmocom.org/docs/pysim/master/html/
self.poutput("")
self.poutput("Card handling (%s) failed with an exception:" % str(self.sl))
self.poutput("---------------------8<---------------------")
traceback.print_exc()
self.poutput(traceback.format_exc().rstrip())
self.poutput("---------------------8<---------------------")
self.poutput("")
fail_count = fail_count + 1
@@ -1176,7 +1176,7 @@ if __name__ == '__main__':
startup_errors = True
print("Card initialization (%s) failed with an exception:" % str(sl))
print("---------------------8<---------------------")
traceback.print_exc()
print(traceback.format_exc().rstrip())
print("---------------------8<---------------------")
if not opts.noprompt:
print("(you may still try to recover from this manually by using the 'equip' command.)")