mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-26 23:38:32 +03:00
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
This commit is contained in:
@@ -485,6 +485,21 @@ def read_params_csv(opts, imsi=None, iccid=None):
|
|||||||
pin_adm = ''.join(['%02x'%(ord(x)) for x in row['adm1']])
|
pin_adm = ''.join(['%02x'%(ord(x)) for x in row['adm1']])
|
||||||
if pin_adm:
|
if pin_adm:
|
||||||
row['pin_adm'] = rpad(pin_adm, 16)
|
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
|
return row
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user