Attention is currently required from: laforge.
fixeria has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/38205?usp=email )
Change subject: bump version to 0.0.4 for the recent hexstr improvements
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/38205?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: I4bc48a5c3546bd8d170bc97f77a9ecf557f933ae
Gerrit-Change-Number: 38205
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Thu, 19 Sep 2024 16:01:04 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: dexter.
laforge has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/38117?usp=email )
Change subject: ts_51_011: replace encoding of EF.MSISDN with construct model
......................................................................
Patch Set 7:
(1 comment)
Patchset:
PS1:
> I wonder how the compatibility layer should be implemented. […]
the mechanism you describe already exists: You keep the he _{en,de}code_record_hex methods, and in the function you check if you need to transform the data. If yes, transform it. And then call the parse_build construct from that method. The object would not have a _construct attribute then.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/38117?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: I647f5c63f7f87902a86c0c5d8e92fdc7f4350a5a
Gerrit-Change-Number: 38117
Gerrit-PatchSet: 7
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 19 Sep 2024 12:46:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: dexter <pmaier(a)sysmocom.de>
Attention is currently required from: dexter.
laforge has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/38195?usp=email )
Change subject: filesystem: pass total_len to construct of when encoding file contents
......................................................................
Patch Set 2:
(1 comment)
File pySim/filesystem.py:
https://gerrit.osmocom.org/c/pysim/+/38195/comment/fb0a4300_36e58f66?usp=em… :
PS2, Line 1338: def _decode_bin(self, raw_bin_data: bytearray):
: chunks = [raw_bin_data[i:i+self.rec_len]
: for i in range(0, len(raw_bin_data), self.rec_len)]
: return [self.decode_record_bin(x) for x in chunks]
:
: def _encode_bin(self, abstract_data) -> bytes:
: chunks = [self.encode_record_bin(x) for x in abstract_data]
: # FIXME: pad to file size
: return b''.join(chunks)
you are not passing the total_len as argument to the self.{encode,decode}_record_bin here. This means the actual file size will not be used, and we will always call self.__get_rec_len(None)
In order to have the total_len available, the calls to _{encode,decode}_bin must be extended with an additional argument, just like the build_construct gets passed the context. (note: there are likely other derived classes that have their own _{en,de}code_bin methods, as they don't use _construct. So you need to change all 'def _{en,de}code_bin' and 'def _{en,de}code_hex' methods of all derived classes to accept the extra argument.
This doesn't cause an error in the test suite, as we don't have tests where the file size is larger than the data we want to write to it. All our tests have fixed-size records and decode/encode to the exact same size, so you don't ever use this.*total_len in the _construct.
So IMHO it's just a lack of test coverage that hides the bug here.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/38195?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: I1b7a51594fbc5d9fe01132c39354a2fa88d53f9b
Gerrit-Change-Number: 38195
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 19 Sep 2024 12:43:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: dexter.
laforge has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/38195?usp=email )
Change subject: filesystem: pass total_len to construct of when encoding file contents
......................................................................
Patch Set 2:
(2 comments)
File pySim/filesystem.py:
https://gerrit.osmocom.org/c/pysim/+/38195/comment/e2ac5f02_73b350c9?usp=em… :
PS1, Line 1043: __get_rec_len
> I have put the double underscore to make the method as private. […]
Done
https://gerrit.osmocom.org/c/pysim/+/38195/comment/4a36e838_555088b7?usp=em… :
PS1, Line 1266: return b2h(filter_dict(build_construct(self._construct, abstract_data, self._get_size(total_len))))
> I still not seeing entirely through here. […]
The current purpose of the TransRecEF is that our _construct only needs to specify the encoding of a single record, instead of N* a record over the entire file. The shell commands are still read_binary / update_binary as IMHO it would be too confusing to have record-oriented shell commands on a transparent file. That could of course be done, but it's not how the current code works.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/38195?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: I1b7a51594fbc5d9fe01132c39354a2fa88d53f9b
Gerrit-Change-Number: 38195
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 19 Sep 2024 12:33:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: dexter <pmaier(a)sysmocom.de>
Attention is currently required from: laforge.
dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/38195?usp=email )
Change subject: filesystem: pass total_len to construct of when encoding file contents
......................................................................
Patch Set 2:
(2 comments)
File pySim/filesystem.py:
https://gerrit.osmocom.org/c/pysim/+/38195/comment/8217c92e_3554c5d8?usp=em… :
PS1, Line 1043: __get_rec_len
> I'm not following your argument here. […]
I have put the double underscore to make the method as private. Also I don't think that the double underscore is exclusively reserved for python internal stuff. At least I haven't read that anywhere yet.
I found an interesting article about the underscore topic:
https://medium.com/python-explainers/single-and-double-underscores-in-pytho…https://gerrit.osmocom.org/c/pysim/+/38195/comment/ca762fc4_fa7dd7f5?usp=em… :
PS1, Line 1266: return b2h(filter_dict(build_construct(self._construct, abstract_data, self._get_size(total_len))))
> TransRecEF registeres the cdm2 command-set form TransparentEF, yes. It will call lchan. […]
I still not seeing entirely through here. I thought TransRecEF were transparent files with multiple fixed length records. But its actually the other way around? I was expected to get the record oriented command set but I get the command set for transparent files but with multiple records in the JSON struct.
In any case, I have tested it and it seems to work fine. The files get updated properly. Also the unittests seem to have coverage, so I think everything should be ok here.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/38195?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: I1b7a51594fbc5d9fe01132c39354a2fa88d53f9b
Gerrit-Change-Number: 38195
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Thu, 19 Sep 2024 09:51:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: dexter <pmaier(a)sysmocom.de>
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/38203?usp=email )
Change subject: osmocom.utils: Return hexstr type form argparse helpers
......................................................................
osmocom.utils: Return hexstr type form argparse helpers
Change-Id: Ide9f3c6b364d867f2dfc1b7dfda40dbab03c5130
---
M src/osmocom/utils.py
1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/python/pyosmocom refs/changes/03/38203/1
diff --git a/src/osmocom/utils.py b/src/osmocom/utils.py
index 6c91783..a218e1b 100644
--- a/src/osmocom/utils.py
+++ b/src/osmocom/utils.py
@@ -203,16 +203,16 @@
raise ValueError('Input must be [hexa]decimal')
if len(instr) & 1:
raise ValueError('Input has un-even number of hex digits')
- return instr
+ return hexstr(instr)
-def is_hexstr(instr: str) -> str:
+def is_hexstr(instr: str) -> hexstr:
"""Method that can be used as 'type' in argparse.add_argument() to validate the value consists of
an even sequence of hexadecimal digits only."""
if not all(c in string.hexdigits for c in instr):
raise ValueError('Input must be hexadecimal')
if len(instr) & 1:
raise ValueError('Input has un-even number of hex digits')
- return instr
+ return hexstr(instr)
def is_decimal(instr: str) -> str:
"""Method that can be used as 'type' in argparse.add_argument() to validate the value consists of
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/38203?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: Ide9f3c6b364d867f2dfc1b7dfda40dbab03c5130
Gerrit-Change-Number: 38203
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>