From ac9dde683fe46e4ac0edf16c842b40fdc06a6e20 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Wed, 4 Jul 2018 11:05:14 +0200 Subject: [PATCH] pysim-prog: add commandline option to probe cards In some situations it may be helpful to know the card name (type) we deal with in advance. So lets ad an to probe that only detects the card and then exists. - Add commandline option -T --probe Change-Id: I57422d3819d52fd215ac8f13f890729aad2af76f Related: OS#3376 --- pySim-prog.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pySim-prog.py b/pySim-prog.py index 1685d2b1..eca8b4ec 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -62,6 +62,10 @@ def parse_options(): help="Card type (user -t list to view) [default: %default]", default="auto", ) + parser.add_option("-T", "--probe", dest="probe", + help="Determine card type", + default=False, action="store_true" + ) parser.add_option("-a", "--pin-adm", dest="pin_adm", help="ADM PIN used for provisioning (overwrites default)", ) @@ -156,6 +160,9 @@ def parse_options(): print kls.name sys.exit(0) + if options.probe: + return options + if options.source == 'csv': if (options.imsi is None) and (options.batch_mode is False) and (options.read_imsi is False): parser.error("CSV mode needs either an IMSI, --read-imsi or batch mode") @@ -525,7 +532,7 @@ def card_detect(opts, scc): for kls in _cards_classes: card = kls.autodetect(scc) if card: - print "Autodetected card type %s" % card.name + print "Autodetected card type: %s" % card.name card.reset() break @@ -540,7 +547,7 @@ def card_detect(opts, scc): card = ctypes[opts.type](scc) else: - raise ValueError("Unknown card type %s" % opts.type) + raise ValueError("Unknown card type: %s" % opts.type) return card @@ -589,6 +596,10 @@ if __name__ == '__main__': else: sys.exit(-1) + # Probe only + if opts.probe: + break; + # Erase if requested if opts.erase: print "Formatting ..."