pySim-trace: display decoded result as JSON, not as python dict

This means users can copy+paste or otherwise post-process the data in a
standard format.

Change-Id: I3135f2f52b8d61684a71b836915b43da5c48422b
This commit is contained in:
Harald Welte
2024-07-19 18:20:14 +02:00
parent 699b49ef1b
commit c800f2a716
2 changed files with 278 additions and 276 deletions

View File

@@ -8,6 +8,7 @@ from pprint import pprint as pp
from pySim.apdu import *
from pySim.runtime import RuntimeState
from pySim.utils import JsonEncoder
from pySim.cards import UiccCardBase
from pySim.commands import SimCardCommands
from pySim.profile import CardProfile
@@ -97,7 +98,8 @@ class Tracer:
"""Output a single decoded + processed ApduCommand."""
if self.show_raw_apdu:
print(apdu)
print("%02u %-16s %-35s %-8s %s %s" % (inst.lchan_nr, inst._name, inst.path_str, inst.col_id, inst.col_sw, inst.processed))
print("%02u %-16s %-35s %-8s %s %s" % (inst.lchan_nr, inst._name, inst.path_str, inst.col_id,
inst.col_sw, json.dumps(inst.processed, cls=JsonEncoder)))
print("===============================")
def format_reset(self, apdu: CardReset):

File diff suppressed because one or more lines are too long