aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2018-07-04 11:05:14 +0200
committerHarald Welte <laforge@gnumonks.org>2018-07-04 11:54:01 +0000
commitac9dde683fe46e4ac0edf16c842b40fdc06a6e20 (patch)
tree62f1d24def41696f41cbb245b6e7caa3bc15c920
parent0e3fcaa1bbe78010d23bf59b6c2f6629feac4627 (diff)
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
-rwxr-xr-xpySim-prog.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pySim-prog.py b/pySim-prog.py
index 1685d2b..eca8b4e 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 ..."