dexter has uploaded this change for review. (
https://gerrit.osmocom.org/c/pysim/+/15431
Change subject: pySim-prog: generate a pin_adm from pin_adm_hex also for CSV
files
......................................................................
pySim-prog: generate a pin_adm from pin_adm_hex also for CSV files
When reading CSV files we currently have no option to provide a
pin_adm_hex field like we already have it as commandline option.
Lets add an option pin_adm_hex for this.
Change-Id: I53e8d666d26a06f580725a8443a335643d10192c
---
M pySim-prog.py
1 file changed, 15 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/31/15431/1
diff --git a/pySim-prog.py b/pySim-prog.py
index 8abce0a..13e8bb5 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -485,6 +485,21 @@
pin_adm = ''.join(['%02x'%(ord(x)) for x in
row['adm1']])
if pin_adm:
row['pin_adm'] = rpad(pin_adm, 16)
+
+ # If the CSV-File defines a pin_adm_hex field use this field to
+ # generate pin_adm from that.
+ pin_adm_hex = row.get('pin_adm_hex')
+ if pin_adm_hex:
+ if len(pin_adm_hex) == 16:
+ row['pin_adm'] = pin_adm_hex
+ # Ensure that it's hex-encoded
+ try:
+ try_encode = h2b(pin_adm)
+ except ValueError:
+ raise ValueError("pin_adm_hex needs to
be hex encoded using this option")
+ else:
+ raise ValueError("pin_adm_hex needs to be
exactly 16 digits (hex encoded)")
+
return row
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/15431
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I53e8d666d26a06f580725a8443a335643d10192c
Gerrit-Change-Number: 15431
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <[email protected]>
Gerrit-MessageType: newchange