<p>Max has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12460">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add option to keep cards' ICCID when programming<br><br>This makes it easier to change only the network-related parameters while<br>keeping SIM-specific data (used for inventory or DB for example) intact.<br><br>Change-Id: I7a9c2fdd6af081fe478f1007bc322f3d7cb8d350<br>---<br>M pySim-prog.py<br>1 file changed, 12 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/60/12460/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim-prog.py b/pySim-prog.py</span><br><span>index d6d7ad5..0c1e634 100755</span><br><span>--- a/pySim-prog.py</span><br><span>+++ b/pySim-prog.py</span><br><span>@@ -128,6 +128,9 @@</span><br><span>     parser.add_option("--read-imsi", dest="read_imsi", action="store_true",</span><br><span>                        help="Read the IMSI from the CARD", default=False</span><br><span>          )</span><br><span style="color: hsl(120, 100%, 40%);">+     parser.add_option("--keep-iccid", dest="keep_iccid", action="store_true",</span><br><span style="color: hsl(120, 100%, 40%);">+                       help="Use ICCID of the card as is", default=False</span><br><span style="color: hsl(120, 100%, 40%);">+           )</span><br><span>    parser.add_option("-z", "--secret", dest="secret", metavar="STR",</span><br><span>                    help="Secret used for ICCID/IMSI autogen",</span><br><span>                 )</span><br><span>@@ -173,8 +176,8 @@</span><br><span>              if options.read_csv is None:</span><br><span>                         parser.error("CSV mode requires a CSV input file")</span><br><span>         elif options.source == 'cmdline':</span><br><span style="color: hsl(0, 100%, 40%);">-               if ((options.imsi is None) or (options.iccid is None)) and (options.num is None):</span><br><span style="color: hsl(0, 100%, 40%);">-                       parser.error("If either IMSI or ICCID isn't specified, num is required")</span><br><span style="color: hsl(120, 100%, 40%);">+                if ((options.imsi is None) or (options.iccid is None)) and (options.num is None) and (options.keep_iccid is False):</span><br><span style="color: hsl(120, 100%, 40%);">+                   parser.error("If either IMSI or ICCID isn't specified, num or keep-iccid is required")</span><br><span>         else:</span><br><span>                parser.error("Only `cmdline' and `csv' sources supported")</span><br><span> </span><br><span>@@ -267,7 +270,9 @@</span><br><span>               iccid = opts.iccid</span><br><span>           if not _isnum(iccid, 19) and not _isnum(iccid, 20):</span><br><span>                  raise ValueError('ICCID must be 19 or 20 digits !');</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+        elif opts.keep_iccid is True:</span><br><span style="color: hsl(120, 100%, 40%);">+                # will be filled by the caller</span><br><span style="color: hsl(120, 100%, 40%);">+                iccid = 0</span><br><span>       else:</span><br><span>                if opts.num is None:</span><br><span>                         raise ValueError('Neither ICCID nor card number specified !')</span><br><span>@@ -620,7 +625,10 @@</span><br><span> </span><br><span>             # Generate parameters</span><br><span>                if opts.source == 'cmdline':</span><br><span style="color: hsl(0, 100%, 40%);">-                    cp = gen_parameters(opts)</span><br><span style="color: hsl(120, 100%, 40%);">+                        cp = gen_parameters(opts)</span><br><span style="color: hsl(120, 100%, 40%);">+                        if opts.keep_iccid is True:</span><br><span style="color: hsl(120, 100%, 40%);">+                                (res, _) = scc.read_binary(EF['ICCID'])</span><br><span style="color: hsl(120, 100%, 40%);">+                                cp['iccid'] = dec_iccid(res)</span><br><span>             elif opts.source == 'csv':</span><br><span>                   if opts.read_imsi:</span><br><span>                           if opts.dry_run:</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12460">change 12460</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12460"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I7a9c2fdd6af081fe478f1007bc322f3d7cb8d350 </div>
<div style="display:none"> Gerrit-Change-Number: 12460 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>