pySim-prog: rename variable card_handler

The variable card_handler is assigned in the following way:

card_handler = card_handler(sl)

This may cause problems since the class name and the variable name are
the same. Lets rename card_handler to avoid problems here.

Change-Id: I84dafc49862e373ae9f6a56bd2e8d1a02c27430a
This commit is contained in:
Philipp Maier
2021-09-17 13:38:36 +02:00
parent c3927ec580
commit 82511e5218

View File

@@ -649,11 +649,11 @@ def save_batch(opts):
fh.close() fh.close()
def process_card(opts, first, card_handler): def process_card(opts, first, ch):
if opts.dry_run is False: if opts.dry_run is False:
# Connect transport # Connect transport
card_handler.get(first) ch.get(first)
if opts.dry_run is False: if opts.dry_run is False:
# Get card # Get card
@@ -681,13 +681,13 @@ def process_card(opts, first, card_handler):
if opts.read_iccid: if opts.read_iccid:
if opts.dry_run: if opts.dry_run:
# Connect transport # Connect transport
card_handler.get(False) ch.get(False)
(res,_) = scc.read_binary(['3f00', '2fe2'], length=10) (res,_) = scc.read_binary(['3f00', '2fe2'], length=10)
iccid = dec_iccid(res) iccid = dec_iccid(res)
elif opts.read_imsi: elif opts.read_imsi:
if opts.dry_run: if opts.dry_run:
# Connect transport # Connect transport
card_handler.get(False) ch.get(False)
(res,_) = scc.read_binary(EF['IMSI']) (res,_) = scc.read_binary(EF['IMSI'])
imsi = swap_nibbles(res)[3:] imsi = swap_nibbles(res)[3:]
else: else:
@@ -713,7 +713,7 @@ def process_card(opts, first, card_handler):
opts.num += 1 opts.num += 1
save_batch(opts) save_batch(opts)
card_handler.done() ch.done()
return 0 return 0
@@ -741,9 +741,9 @@ if __name__ == '__main__':
init_batch(opts) init_batch(opts)
if opts.card_handler: if opts.card_handler:
card_handler = card_handler_auto(sl, opts.card_handler) ch = card_handler_auto(sl, opts.card_handler)
else: else:
card_handler = card_handler(sl) ch = card_handler(sl)
# Iterate # Iterate
first = True first = True
@@ -751,7 +751,7 @@ if __name__ == '__main__':
while 1: while 1:
try: try:
rc = process_card(opts, first, card_handler) rc = process_card(opts, first, ch)
except (KeyboardInterrupt): except (KeyboardInterrupt):
print("") print("")
print("Terminated by user!") print("Terminated by user!")
@@ -770,7 +770,7 @@ if __name__ == '__main__':
# Something did not work as well as expected, however, lets # Something did not work as well as expected, however, lets
# make sure the card is pulled from the reader. # make sure the card is pulled from the reader.
if rc != 0: if rc != 0:
card_handler.error() ch.error()
# If we are not in batch mode we are done in any case, so lets # If we are not in batch mode we are done in any case, so lets
# exit here. # exit here.