Fix compatibility with Python 3: print() is a function
Change-Id: I5dd8e5daf420fc8667c5156bfacc8763d8895993
diff --git a/pySim-prog.py b/pySim-prog.py
index b070c5e..bfb40b2 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -173,7 +173,7 @@
if options.type == 'list':
for kls in _cards_classes:
- print kls.name
+ print(kls.name)
sys.exit(0)
if options.probe:
@@ -560,7 +560,7 @@
for k in BATCH_INCOMPATIBLE:
if getattr(opts, k):
- print "Incompatible option with batch_state: %s" % (k,)
+ print("Incompatible option with batch_state: %s" % (k,))
sys.exit(-1)
# Don't load state if there is none ...
@@ -568,7 +568,7 @@
return
if not os.path.isfile(opts.batch_state):
- print "No state file yet"
+ print("No state file yet")
return
# Get stored data
@@ -601,12 +601,12 @@
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
if card is None:
- print "Autodetection failed"
+ print("Autodetection failed")
return
if opts.type == "auto_once":
@@ -631,7 +631,7 @@
# Get card
card = card_detect(opts, scc)
if card is None:
- print "No card detected!"
+ print("No card detected!")
return -1
# Probe only
@@ -640,7 +640,7 @@
# Erase if requested
if opts.erase:
- print "Formatting ..."
+ print("Formatting ...")
card.erase()
card.reset()
@@ -666,16 +666,16 @@
imsi = opts.imsi
cp = read_params_csv(opts, imsi=imsi, iccid=iccid)
if cp is None:
- print "Error reading parameters from CSV file!\n"
+ print("Error reading parameters from CSV file!\n")
return 2
print_parameters(cp)
if opts.dry_run is False:
# Program the card
- print "Programming ..."
+ print("Programming ...")
card.program(cp)
else:
- print "Dry Run: NOT PROGRAMMING!"
+ print("Dry Run: NOT PROGRAMMING!")
# Write parameters permanently
write_parameters(opts, cp)
@@ -716,9 +716,9 @@
# If we use a CSV file as data input, check if the CSV file exists.
if opts.source == 'csv':
- print "Using CSV file as data input: " + str(opts.read_csv)
+ print("Using CSV file as data input: " + str(opts.read_csv))
if not os.path.isfile(opts.read_csv):
- print "CSV file not found!"
+ print("CSV file not found!")
sys.exit(1)
# Batch mode init
@@ -737,18 +737,18 @@
try:
rc = process_card(opts, first, card_handler)
except (KeyboardInterrupt):
- print ""
- print "Terminated by user!"
+ print("")
+ print("Terminated by user!")
sys.exit(0)
except (SystemExit):
raise
except:
- print ""
- print "Card programming failed with an execption:"
- print "---------------------8<---------------------"
+ print("")
+ print("Card programming failed with an execption:")
+ print("---------------------8<---------------------")
traceback.print_exc()
- print "---------------------8<---------------------"
- print ""
+ print("---------------------8<---------------------")
+ print("")
rc = -1
# Something did not work as well as expected, however, lets