mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-16 18:38:32 +03:00
pySim-prog, pySim-shell do not use global variables
When __main__ runs different variables get assigned. In particular opts, scc, sl and ch. Those variables are available in any scope and technically it is possible to access them. However, lets not do this since it leads to confusion. Also, pylint will complain about those code locations. In pySim-shell.py - Let's use the proper locations (sl and ch are stored in PysimApp. - Scc can be assigned in init_card. - In method walk, the use of the variable opts to call ection_df is wrong, lets use **kwargs (see also usage of action_ef). - The constructor of Cmd2ApduTracer has a parameter cmd2_app, but usese the global variable app. Let's use cmd2_app instead. In pySim-prog.py - Do not use opts.num in find_row_in_csv_file, use num instead. - Pass scc to process_card as parameter so that it won't access scc in the global scope. Change-Id: I7f09e9a6a6bfc658de75e86f7383ce73726f6666 Related: OS#6210
This commit is contained in:
@@ -567,7 +567,7 @@ def find_row_in_csv_file(csv_file_name:str, num=None, iccid=None, imsi=None):
|
||||
for row in cr:
|
||||
# Pick a specific row by line number (num)
|
||||
if num is not None and iccid is None and imsi is None:
|
||||
if opts.num == i:
|
||||
if num == i:
|
||||
f.close()
|
||||
return row
|
||||
|
||||
@@ -727,7 +727,7 @@ def save_batch(opts):
|
||||
fh.close()
|
||||
|
||||
|
||||
def process_card(opts, first, ch):
|
||||
def process_card(scc, opts, first, ch):
|
||||
|
||||
# Connect transport
|
||||
ch.get(first)
|
||||
@@ -821,7 +821,7 @@ if __name__ == '__main__':
|
||||
|
||||
while 1:
|
||||
try:
|
||||
rc = process_card(opts, first, ch)
|
||||
rc = process_card(scc, opts, first, ch)
|
||||
except (KeyboardInterrupt):
|
||||
print("")
|
||||
print("Terminated by user!")
|
||||
|
||||
Reference in New Issue
Block a user