Change in pysim[master]: pySim-shells: complete CHV/PIN management tools

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

laforge gerrit-no-reply at lists.osmocom.org
Mon Mar 29 20:55:45 UTC 2021


laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/23541 )

Change subject: pySim-shells: complete CHV/PIN management tools
......................................................................


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/c/pysim/+/23541/1/pySim/commands.py 
File pySim/commands.py:

https://gerrit.osmocom.org/c/pysim/+/23541/1/pySim/commands.py@245 
PS1, Line 245: RuntimeError('Failed to change chv_no 0x%02X with code 0x%s, %i tries left.' % (chv_no, b2h(pin_code).upper(), int(sw[3])))
I'm seeing so many repetitions of this line and the arguments, and the functions converting the arguments.  It may make sense to create a derived ChvRuntimeError class, to which you simply pass arguments without conversion, like
    raise ChvRuntimeError('change', chv_no, pin_code, sw)

and leaving all the conversion and string formatting to the Exception class. Looks much more structured, IMHO.

Actually, all of the surrounding code (if sw_match ... elsif 9000, ...) is copy+pasted, too.  So rather than the above (or in addition to it) you can create a function that does all of this  something like 

def _chv_process_sw(chv_no, pin_code, sw):
   if sw_match(sw, '63xcx'):
       ....
   elif (sw != '9000'):
       raise ...
   return (data, sw)

And then use return _chv_process_sw(chv_no, pin_code, sw) in all of these functions.



-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23541
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic89446e6bd2021095e579fb6b20458df48ba6413
Gerrit-Change-Number: 23541
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge <laforge at osmocom.org>
Gerrit-Comment-Date: Mon, 29 Mar 2021 20:55:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210329/96d3a07e/attachment.htm>


More information about the gerrit-log mailing list