Change in ...pysim[master]: pySim-prog: generate a pin_adm from pin_adm_hex also for CSV files

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Fri Sep 6 08:34:11 UTC 2019


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 <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190906/7ef75341/attachment.htm>


More information about the gerrit-log mailing list