net-sim: bundle the MCC/MNC list and hide MVNOs from the picker (v2.7.7)
The operator picker depended on a workspace file outside the repo
(<workspace>/samples/mcc-mnc-list.json), so a fresh clone showed
'Operator list not loaded'.
- bundle the list in the package (pysim_simple_server/data/
mcc-mnc-list.json, byte-identical to pbakondy/mcc-mnc-list master
commit 97bc1652, MIT) with license + provenance in
mcc-mnc-list.LICENSE; declared as package data so wheels carry it
- _default_mcc_mnc_list() now points at the bundled file;
--mcc-mnc-list still overrides it
- hide MVNO entries from the simulator picker (search + random): they
do not operate their own network. Detected via the `bands` field
('MVNO', 'Satellite MVNO', ...); the full list stays loaded so the
Network state panel still resolves operator names
- tests/test_mcc_mnc.py: bundled file ships/parses, marker variants,
search/random filters on fixtures and on the real list
- README/AGENTS updated; version trio 2.7.7; sw cache simple-v210
This commit is contained in:
@@ -29,11 +29,11 @@ def _default_web_dir():
|
||||
|
||||
|
||||
def _default_mcc_mnc_list():
|
||||
# Workspace default: the CC-BY-SA operator list lives outside the repo
|
||||
# (<workspace>/samples/mcc-mnc-list.json); clones can point elsewhere with
|
||||
# --mcc-mnc-list and the endpoint reports available=false when missing.
|
||||
repo = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
return os.path.normpath(os.path.join(repo, '..', 'samples', 'mcc-mnc-list.json'))
|
||||
# Bundled default: the MIT-licensed operator list ships with the package
|
||||
# (data/mcc-mnc-list.json, from pbakondy/mcc-mnc-list); --mcc-mnc-list
|
||||
# overrides it and the endpoint reports available=false when missing.
|
||||
pkg = os.path.dirname(os.path.abspath(__file__))
|
||||
return os.path.join(pkg, 'data', 'mcc-mnc-list.json')
|
||||
|
||||
|
||||
def main():
|
||||
@@ -47,7 +47,7 @@ def main():
|
||||
parser.add_argument('--web-dir', default=_default_web_dir(), metavar='PATH',
|
||||
help='Directory with the SIMple PWA static files to serve (default: <repo>/frontend)')
|
||||
parser.add_argument('--mcc-mnc-list', default=_default_mcc_mnc_list(), metavar='PATH',
|
||||
help='Worldwide MCC/MNC operator list (JSON) for the network-simulation operator picker (default: <workspace>/samples/mcc-mnc-list.json)')
|
||||
help='Worldwide MCC/MNC operator list (JSON) for the network-simulation operator picker (default: the bundled data/mcc-mnc-list.json)')
|
||||
parser.add_argument('--log-requests', action='store_true', default=False, help='Log request/response payloads to stderr')
|
||||
parser.add_argument('--sms-oa', default='12345', metavar='DIGITS',
|
||||
help='TP-Originating-Address (SMSC number) for the SMS-DELIVER TPDU (default: 12345)')
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
mcc-mnc-list.json — worldwide MCC/MNC operator list (incl. MVNO entries)
|
||||
|
||||
Source: https://github.com/pbakondy/mcc-mnc-list
|
||||
mcc-mnc-list.json, commit 97bc165252bb9bb5b37946898ec556c29a38feb8
|
||||
(2023-04-04); retrieved 2026-09-20
|
||||
md5 e63af9bc0beb651575a457d53c2e6fdd
|
||||
Data: derived from the Wikipedia article "Mobile country code"
|
||||
(https://en.wikipedia.org/wiki/Mobile_country_code)
|
||||
|
||||
The Network simulation operator picker hides entries whose `bands` field
|
||||
marks them as MVNO (they do not operate their own radio network); the full
|
||||
list is kept so the Network state panel can still resolve operator names.
|
||||
|
||||
--- upstream license -------------------------------------------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Peter Bakondy
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,7 @@ from osmocom.construct import GsmOrUcs2Adapter
|
||||
from osmocom.tlv import BER_TLV_IE
|
||||
|
||||
|
||||
VERSION = '2.7.6'
|
||||
VERSION = '2.7.7'
|
||||
|
||||
MAX_ENVELOPE_SEGMENTS = 5 # max SMS segments for outgoing C-APDU in ENVELOPE
|
||||
|
||||
@@ -461,6 +461,15 @@ def _mcc_mnc_load(path):
|
||||
return data
|
||||
|
||||
|
||||
def _mcc_mnc_is_mvno(e):
|
||||
"""True for MVNO entries: `bands` marks them (e.g. 'MVNO', 'Satellite MVNO').
|
||||
|
||||
MVNOs do not operate their own radio network, so the network-simulation
|
||||
picker hides them; the full list is kept for operator-name resolution.
|
||||
"""
|
||||
return 'mvno' in str(e.get('bands') or '').lower()
|
||||
|
||||
|
||||
def _mcc_mnc_search(data, query, limit=50):
|
||||
"""Compact substring search over country/brand/operator/MCC/MNC."""
|
||||
q = (query or '').strip().lower()
|
||||
@@ -468,6 +477,8 @@ def _mcc_mnc_search(data, query, limit=50):
|
||||
return []
|
||||
out = []
|
||||
for e in data or []:
|
||||
if _mcc_mnc_is_mvno(e):
|
||||
continue
|
||||
hay = ' '.join(str(e.get(k) or '') for k in
|
||||
('countryName', 'countryCode', 'mcc', 'mnc', 'brand', 'operator')).lower()
|
||||
if q not in hay:
|
||||
@@ -482,9 +493,10 @@ def _mcc_mnc_search(data, query, limit=50):
|
||||
def _mcc_mnc_random(data, exclude=None):
|
||||
"""One random operator entry (optionally excluding 'mccmnc' digits)."""
|
||||
pool = [e for e in (data or [])
|
||||
if (str(e.get('mcc') or '') + str(e.get('mnc') or '')) != (exclude or '')]
|
||||
if (str(e.get('mcc') or '') + str(e.get('mnc') or '')) != (exclude or '')
|
||||
and not _mcc_mnc_is_mvno(e)]
|
||||
if not pool:
|
||||
pool = data or []
|
||||
pool = [e for e in (data or []) if not _mcc_mnc_is_mvno(e)]
|
||||
if not pool:
|
||||
return None
|
||||
e = random.choice(pool)
|
||||
|
||||
Reference in New Issue
Block a user