Change in osmo-sim-auth[master]: Convert to Python3 using 2to3

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/.

Ludovic Rousseau gerrit-no-reply at lists.osmocom.org
Sun Oct 25 13:36:51 UTC 2020


Ludovic Rousseau has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sim-auth/+/20895 )


Change subject: Convert to Python3 using 2to3
......................................................................

Convert to Python3 using 2to3

Change-Id: I70a95fec06a18ff6ebedcc1b6c48a16304047770
---
M osmo-sim-auth.py
1 file changed, 22 insertions(+), 22 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sim-auth refs/changes/95/20895/1

diff --git a/osmo-sim-auth.py b/osmo-sim-auth.py
index 6ba9557..3224e15 100755
--- a/osmo-sim-auth.py
+++ b/osmo-sim-auth.py
@@ -30,61 +30,61 @@
 def handle_usim(options, rand_bin, autn_bin):
 	u = USIM()
 	if not u:
-		print "Error opening USIM"
+		print("Error opening USIM")
 		exit(1)
 
 	if options.debug:
 		u.dbg = 2;
 
 	imsi = u.get_imsi()
-	print "Testing USIM card with IMSI %s" % imsi
+	print("Testing USIM card with IMSI %s" % imsi)
 
-	print "\nUMTS Authentication"
+	print("\nUMTS Authentication")
 	ret = u.authenticate(rand_bin, autn_bin, ctx='3G')
         if ret == None:
-                print "UMTS Authentication failed"
+                print("UMTS Authentication failed")
                 exit(1)
 	if len(ret) == 1:
-		print "AUTS:\t%s" % b2a_hex(byteToString(ret[0]))
+		print("AUTS:\t%s" % b2a_hex(byteToString(ret[0])))
 	else:
-		print "RES:\t%s" % b2a_hex(byteToString(ret[0]))
-		print "CK:\t%s" % b2a_hex(byteToString(ret[1]))
-		print "IK:\t%s" % b2a_hex(byteToString(ret[2]))
+		print("RES:\t%s" % b2a_hex(byteToString(ret[0])))
+		print("CK:\t%s" % b2a_hex(byteToString(ret[1])))
+		print("IK:\t%s" % b2a_hex(byteToString(ret[2])))
 		if len(ret) == 4:
-			print "Kc:\t%s" % b2a_hex(byteToString(ret[3]))
+			print("Kc:\t%s" % b2a_hex(byteToString(ret[3])))
 
-	print "\nGSM Authentication"
+	print("\nGSM Authentication")
 	ret = u.authenticate(rand_bin, autn_bin, ctx='2G')
 	if not len(ret) == 2:
-		print "Error during 2G authentication"
+		print("Error during 2G authentication")
 		exit(1)
-	print "SRES:\t%s" % b2a_hex(byteToString(ret[0]))
-	print "Kc:\t%s" % b2a_hex(byteToString(ret[1]))
+	print("SRES:\t%s" % b2a_hex(byteToString(ret[0])))
+	print("Kc:\t%s" % b2a_hex(byteToString(ret[1])))
 
 def handle_sim(options, rand_bin):
 	s= SIM()
 	if not s:
-		print "Error opening SIM"
+		print("Error opening SIM")
 		exit(1)
 
 	imsi = s.get_imsi()
 	if not options.ipsec:
-		print "Testing SIM card with IMSI %s" % imsi
-		print "\nGSM Authentication"
+		print("Testing SIM card with IMSI %s" % imsi)
+		print("\nGSM Authentication")
 
 	ret = s.run_gsm_alg(rand_bin)
 
 	if not options.ipsec:
-		print "SRES:\t%s" % b2a_hex(byteToString(ret[0]))
-		print "Kc:\t%s" % b2a_hex(byteToString(ret[1]))
+		print("SRES:\t%s" % b2a_hex(byteToString(ret[0])))
+		print("Kc:\t%s" % b2a_hex(byteToString(ret[1])))
 
 	if options.ipsec:
-		print "1%s at uma.mnc%s.mcc%s.3gppnetwork.org,%s,%s,%s" % (imsi, imsi[3:6], imsi[0:3], b2a_hex(byteToString(rand_bin)), b2a_hex(byteToString(ret[0])), b2a_hex(byteToString(ret[1])))
+		print("1%s at uma.mnc%s.mcc%s.3gppnetwork.org,%s,%s,%s" % (imsi, imsi[3:6], imsi[0:3], b2a_hex(byteToString(rand_bin)), b2a_hex(byteToString(ret[0])), b2a_hex(byteToString(ret[1]))))
 
 def handle_sim_info(options):
 	s= SIM()
 	if not s:
-		print "Error opening SIM"
+		print("Error opening SIM")
 		exit(1)
 
 	if options.debug:
@@ -117,7 +117,7 @@
 		exit(2)
 
 	if not options.rand:
-		print "You have to specify RAND"
+		print("You have to specify RAND")
 		exit(2)
 
 	rand_bin = stringToByte(a2b_hex(options.rand))
@@ -128,7 +128,7 @@
 		handle_sim(options, rand_bin)
 	else:
 		if not options.autn:
-			print "You have to specify AUTN"
+			print("You have to specify AUTN")
 			exit(2)
 		handle_usim(options, rand_bin, autn_bin)
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-sim-auth/+/20895
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sim-auth
Gerrit-Branch: master
Gerrit-Change-Id: I70a95fec06a18ff6ebedcc1b6c48a16304047770
Gerrit-Change-Number: 20895
Gerrit-PatchSet: 1
Gerrit-Owner: Ludovic Rousseau <ludovic.rousseau+osmocom at free.fr>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201025/3ed538b5/attachment.htm>


More information about the gerrit-log mailing list