summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAdam Smith <adamsmith@yzguy.io>2026-09-29 19:21:15 +0000
committerAdam Smith <adamsmith@yzguy.io>2026-09-29 19:21:15 +0000
commit002050d158356078931d1a196538b5803eab788e (patch)
tree0852d84d388284673a2a675550aef883169bb8f0 /python
parent90887491e9c0d122c8760195f37e01b1e7e8cdcc (diff)
downloadvyos-1x-002050d158356078931d1a196538b5803eab788e.tar.gz
vyos-1x-002050d158356078931d1a196538b5803eab788e.zip
wwan: T7487: move json/wait_for imports into their only callers
Requested by c-po: json.loads and wait_for were only used by _modem_owning_port() and modem_index()'s wait branch respectively, so importing them at module level cost every other caller of this module an import it does not need.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/utils/wwan.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/python/vyos/utils/wwan.py b/python/vyos/utils/wwan.py
index 6b708e39c..af719571d 100644
--- a/python/vyos/utils/wwan.py
+++ b/python/vyos/utils/wwan.py
@@ -25,11 +25,9 @@ would have done.
import os
-from json import loads
from time import sleep
from vyos.utils.dict import dict_search
-from vyos.utils.misc import wait_for
from vyos.utils.process import call
from vyos.utils.process import cmdl
from vyos.utils.process import DEVNULL
@@ -58,6 +56,8 @@ admin_disconnect_dir = '/run/vyos-wwan'
def _modem_owning_port(ifname: str):
"""Return the ModemManager modem index whose own port list includes
ifname, or None if no currently-known modem owns it."""
+ from json import loads
+
try:
modem_list = loads(cmdl(['mmcli', '--list-modems', '--output-json'])).get(
'modem-list', []
@@ -100,6 +100,8 @@ def modem_index(ifname: str, wait: bool = False):
if not wait:
return _modem_owning_port(ifname)
+ from vyos.utils.misc import wait_for
+
index = None
def _resolve():