dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41738?usp=email )
Change subject: pySim-shell: output git hash in case get_distribution fails
......................................................................
pySim-shell: output git hash in case get_distribution fails
In case pySim-shell is used directly from the git repository (not
installed via a package manager), the version command fails with an
exception because pkg_resources.get_distribution('pySim') fails. In
that case, let's check if pySim-shell.py is inside a git repository
and if so, get the HEAD commit hash and display it instead.
Related: OS#6830
Change-Id: I2b9038f88cfcaa07894a2f09c7f5ad8a5474083d
---
M pySim-shell.py
1 file changed, 12 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/38/41738/1
diff --git a/pySim-shell.py b/pySim-shell.py
index a8b15d5..96658d3 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -520,7 +520,18 @@
def do_version(self, opts):
"""Print the pySim software version."""
import pkg_resources
- self.poutput(pkg_resources.get_distribution('pySim'))
+ from pkg_resources import DistributionNotFound
+ try:
+ self.poutput(pkg_resources.get_distribution('pySim'))
+ except DistributionNotFound as e:
+ import subprocess
+ import os
+ cwd = os.path.dirname(os.path.realpath(__file__))
+ if os.path.isdir(cwd + "/.git"):
+ version = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip()
+ self.poutput("pySim-git-" + version)
+ else:
+ raise(e)
@with_default_category('pySim Commands')
class PySimCommands(CommandSet):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41738?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I2b9038f88cfcaa07894a2f09c7f5ad8a5474083d
Gerrit-Change-Number: 41738
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41735?usp=email )
Change subject: pySim.esim.saip.personalization: Support for EF.SMPP personalization
......................................................................
pySim.esim.saip.personalization: Support for EF.SMPP personalization
It's a not-too-uncommon requirement to modify the SMSC address stored in
EF.SMPP. This adds a ConfigurableParameter for this purpose.
Change-Id: I6b0776c2e753e0a6d158a8cf65cb030977782ec2
---
M pySim/esim/saip/personalization.py
1 file changed, 43 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/35/41735/1
diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index 71f115d..a1df068 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -22,6 +22,7 @@
from osmocom.tlv import camel_to_snake
from pySim.utils import enc_iccid, enc_imsi, h2b, rpad, sanitize_iccid
from pySim.esim.saip import ProfileElement, ProfileElementSequence
+from pySim.ts_51_011 import EF_SMSP
def remove_unwanted_tuples_from_list(l: List[Tuple], unwanted_keys: List[str]) -> List[Tuple]:
"""In a list of tuples, remove all tuples whose first part equals 'unwanted_key'."""
@@ -104,6 +105,48 @@
file_replace_content(pe.decoded['ef-acc'], acc.to_bytes(2, 'big'))
# TODO: DF.GSM_ACCESS if not linked?
+class SmspTpScAddr(ConfigurableParameter):
+ """Configurable SMSC (SMS Service Centre) TP-SC-ADDR. Expects to be a phone number in national or
+ international format (designated by a leading +). Automatically sets the NPI to E.164 and the TON based on
+ presence or absence of leading +"""
+
+ def validate(self):
+ addr_str = str(self.input_value)
+ if addr_str[0] == '+':
+ digits = addr_str[1:]
+ international = True
+ else:
+ digits = addr_str
+ international = False
+ if len(digits) > 20:
+ raise ValueError('TP-SC-ADDR must not exceed 20 digits')
+ if not digits.isdecimal():
+ raise ValueError('TP-SC-ADDR must only contain decimal digits')
+ self.value = (international, digits)
+
+ def apply(self, pes: ProfileElementSequence):
+ international, digits = self.value
+ for pe in pes.get_pes_for_type('usim'):
+ # obtain the File instance from the ProfileElementUSIM
+ f_smsp = pe.files['ef-smsp']
+ #print("SMSP (orig): %s" % f_smsp.body)
+ # instantiate the pySim.ts_51_011.EF_SMSP class for decode/encode
+ ef_smsp = EF_SMSP()
+ # decode the existing file body
+ ef_smsp_dec = ef_smsp.decode_record_bin(f_smsp.body, 1)
+ # patch the actual number
+ ef_smsp_dec['tp_sc_addr']['call_number'] = digits
+ # patch the NPI to isdn_e164
+ ef_smsp_dec['tp_sc_addr']['ton_npi']['numbering_plan_id'] = 'isdn_e164'
+ # patch the TON to international or unknown depending on +
+ ef_smsp_dec['tp_sc_addr']['ton_npi']['type_of_number'] = 'international' if international else 'unknown'
+ # ensure the parameter_indicators.tp_sc_addr is True
+ ef_smsp_dec['parameter_indicators']['tp_sc_addr'] = True
+ # re-encode into the File body
+ f_smsp.body = ef_smsp.encode_record_bin(ef_smsp_dec, 1)
+ #print("SMSP (new): %s" % f_smsp.body)
+ # re-generate the pe.decoded member from the File instance
+ pe.file2pe(f_smsp)
class SdKey(ConfigurableParameter, metaclass=ClassVarMeta):
"""Configurable Security Domain (SD) Key. Value is presented as bytes."""
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41735?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I6b0776c2e753e0a6d158a8cf65cb030977782ec2
Gerrit-Change-Number: 41735
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41736?usp=email )
Change subject: pySim.esim.saip.ProfileElementSequence: Update type annotations
......................................................................
pySim.esim.saip.ProfileElementSequence: Update type annotations
The type annotations didn't reflect reality in two cases.
Change-Id: Ib99c00a38bf009c63180b4a593d6cc796ff282d3
---
M pySim/esim/saip/__init__.py
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/36/41736/1
diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py
index 6e8823b..f661745 100644
--- a/pySim/esim/saip/__init__.py
+++ b/pySim/esim/saip/__init__.py
@@ -1786,7 +1786,7 @@
return None
@staticmethod
- def peclass_for_path(path: Path) -> Optional[ProfileElement]:
+ def peclass_for_path(path: Path) -> (Optional[ProfileElement], Optional[templates.FileTemplate]):
"""Return the ProfileElement class that can contain a file with given path."""
naa = ProfileElementSequence.naa_for_path(path)
if naa:
@@ -1819,7 +1819,7 @@
return ProfileElementTelecom, ft
return ProfileElementGFM, None
- def pe_for_path(self, path: Path) -> Optional[ProfileElement]:
+ def pe_for_path(self, path: Path) -> (Optional[ProfileElement], Optional[templates.FileTemplate]):
"""Return the ProfileElement instance that can contain a file with matching path. This will
either be an existing PE within the sequence, or it will be a newly-allocated PE that is
inserted into the sequence."""
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41736?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib99c00a38bf009c63180b4a593d6cc796ff282d3
Gerrit-Change-Number: 41736
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41737?usp=email )
Change subject: esim.saip: Better docstring about FsNode class
......................................................................
esim.saip: Better docstring about FsNode class
Change-Id: Id9d196e8d9b1d1b892ec50100b170d72d2c3910b
---
M pySim/esim/saip/__init__.py
1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/37/41737/1
diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py
index f661745..dacd35e 100644
--- a/pySim/esim/saip/__init__.py
+++ b/pySim/esim/saip/__init__.py
@@ -1885,7 +1885,10 @@
class FsNode:
- """A node in the filesystem hierarchy."""
+ """A node in the filesystem hierarchy. Each node can have a parent node and any number of children.
+ Each node is identified uniquely within the parent by its numeric FID and its optional human-readable
+ name. Each node usually is associated with an instance of the File class for the actual content of
+ the file. FsNode is the base class used by more specific nodes, such as FsNode{EF,DF,ADF,MF}."""
def __init__(self, fid: int, parent: Optional['FsNode'], file: Optional[File] = None,
name: Optional[str] = None):
self.fid = fid
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41737?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id9d196e8d9b1d1b892ec50100b170d72d2c3910b
Gerrit-Change-Number: 41737
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41734?usp=email )
Change subject: esim.saip.FsProfileElement: Add file2pe() for single file conversion
......................................................................
esim.saip.FsProfileElement: Add file2pe() for single file conversion
We've had files2pe() for re-encoding all of the files, but let's add
a specific one for re-encoding only one of the files (such as commonly
needed during personalization)
Change-Id: I7b7f61aae6b7df6946dadf2f78fddf92995603ec
---
M pySim/esim/saip/__init__.py
1 file changed, 5 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/34/41734/1
diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py
index 1c0c715..6e8823b 100644
--- a/pySim/esim/saip/__init__.py
+++ b/pySim/esim/saip/__init__.py
@@ -633,8 +633,12 @@
self.pe_sequence.cur_df = pe_df
self.pe_sequence.cur_df = self.pe_sequence.cur_df.add_file(file)
+ def file2pe(self, f: File):
+ """Update the "decoded" member for the given file with the contents from the given File."""
+ self.decoded[f.pe_name] = f.to_tuples()
+
def files2pe(self):
- """Update the "decoded" member with the contents of the "files" member."""
+ """Update the "decoded" member for each file with the contents of the "files" member."""
for k, f in self.files.items():
self.decoded[k] = f.to_tuples()
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41734?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I7b7f61aae6b7df6946dadf2f78fddf92995603ec
Gerrit-Change-Number: 41734
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/41731?usp=email )
Change subject: osmocom.construct.PaddedBcdAdapter: Support zero-length strings
......................................................................
osmocom.construct.PaddedBcdAdapter: Support zero-length strings
We cannot use the [-1] slicing if the input string has zero length.
Fix typo in docstring while we're touching that class anyway.
Change-Id: Ib5afb5ab5c2bc9b519dc92818fc6974f7eecba16
---
M src/osmocom/construct.py
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/python/pyosmocom refs/changes/31/41731/1
diff --git a/src/osmocom/construct.py b/src/osmocom/construct.py
index d369bc7..548f22d 100644
--- a/src/osmocom/construct.py
+++ b/src/osmocom/construct.py
@@ -262,11 +262,11 @@
return h2b(swap_nibbles(obj))
class PaddedBcdAdapter(BcdAdapter):
- """Representatin of a BCD string of potentially odd number of BCD digits,
+ """Representation of a BCD string of potentially odd number of BCD digits,
which then need to be padded at the end with an 'f' nibble."""
def _decode(self, obj, context, path):
r = super()._decode(obj, context, path)
- if r[-1] == 'f':
+ if len(r) >= 1 and r[-1] == 'f':
return r[:-1]
else:
return r
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/41731?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: Ib5afb5ab5c2bc9b519dc92818fc6974f7eecba16
Gerrit-Change-Number: 41731
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Attention is currently required from: fixeria, laforge.
dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/41713?usp=email )
Change subject: pysim/log: also accept ANSI strings to specify the log message colors
......................................................................
Patch Set 3:
(1 comment)
File pySim/log.py:
https://gerrit.osmocom.org/c/pysim/+/41713/comment/98801bb5_2bb58a62?usp=em… :
PS1, Line 111: if type(color) is str:
> I believe Harald's suggestion was to do `isinstance(color, str)` instead of `type(color) is str`, bu […]
I think I missed the line - it worked when I tested it with an ANSI string ;-/
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41713?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I93543e19649064043ae8323f82ecd8c423d1d921
Gerrit-Change-Number: 41713
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 19 Dec 2025 15:26:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Comment-In-Reply-To: dexter <pmaier(a)sysmocom.de>
Attention is currently required from: daniel, fixeria, laforge.
Hello Jenkins Builder, daniel, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/41508?usp=email
to look at the new patch set (#8).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: card_key_provider: add PostgreSQL support
......................................................................
card_key_provider: add PostgreSQL support
The Card Key Provider currently only has support for CSV files
as input. Unfortunately using CSV files does not scale very well
when the card inventory is very large and continously updated.
In this case a centralized storage in the form of a database
is the more suitable approach.
This patch adds PostgreSQL support next to the existing CSV
file support. It also adds an importer tool to import existing
CSV files into the database.
Change-Id: Icba625c02a60d7e1f519b506a46bda5ded0537d3
Related: SYS#7725
---
A contrib/csv-to-pgsql.py
M docs/card-key-provider.rst
M pySim-shell.py
M pySim/card_key_provider.py
M setup.py
5 files changed, 586 insertions(+), 10 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/08/41508/8
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41508?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Icba625c02a60d7e1f519b506a46bda5ded0537d3
Gerrit-Change-Number: 41508
Gerrit-PatchSet: 8
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>