[+] add interfaces_index
This commit is contained in:
parent
202bf85f55
commit
799280f074
@ -1,5 +1,7 @@
|
||||
import shutil
|
||||
import glob
|
||||
import subprocess
|
||||
import pydantic
|
||||
import pathlib
|
||||
import ctypes
|
||||
import os
|
||||
@ -93,9 +95,9 @@ def runtime_libdirs_init(
|
||||
raise NotImplementedError
|
||||
|
||||
class interfaces_index_t:
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@dataclasses.dataclass
|
||||
class Interface:
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@dataclasses.dataclass
|
||||
class AddrInfo:
|
||||
family: str
|
||||
local: str
|
||||
@ -103,32 +105,13 @@ class interfaces_index_t:
|
||||
name: str
|
||||
addr_info: list[AddrInfo]
|
||||
|
||||
def interfaces_index() -> list[Interfaces]:
|
||||
ip_addr_res: Any = json.loads(
|
||||
def interfaces_index() -> list[interfaces_index_t.Interface]:
|
||||
res = pydantic.RootModel[
|
||||
list[interfaces_index_t.Interface]
|
||||
].model_validate_json(
|
||||
subprocess.check_output([
|
||||
'ip', '-j', 'addr',
|
||||
]).decode('utf-8')
|
||||
)
|
||||
).root
|
||||
|
||||
assert isinstance(ip_addr_res, list)
|
||||
|
||||
ip_addr_res2 = cast(list[Any], p_addr_res,)
|
||||
|
||||
assert all([
|
||||
isinstance(o, dict)
|
||||
for o in ip_addr_res2.items()
|
||||
])
|
||||
|
||||
ip_addr_res3 = cast(list[dict[Any, Any]], ip_addr_res2)
|
||||
|
||||
assert all([
|
||||
assert isinstance(k, str)
|
||||
for k, v in o.items()
|
||||
for o in ip_addr_res3
|
||||
])
|
||||
|
||||
ip_addr_res4 = cast(list[dict[str, Any]], ip_addr_res3)
|
||||
|
||||
res : list[interfaces_index_t.Interface] = []
|
||||
|
||||
for o in ip_addr_res4:
|
||||
return res
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = 'online.fxreader.pr34'
|
||||
version = '0.1.5.9'
|
||||
version = '0.1.5.9+27.1'
|
||||
|
||||
dependencies = [
|
||||
#"-r requirements.txt",
|
||||
|
BIN
releases/whl/online_fxreader_pr34-0.1.5.9+27.1-py3-none-any.whl
(Stored with Git LFS)
Normal file
BIN
releases/whl/online_fxreader_pr34-0.1.5.9+27.1-py3-none-any.whl
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user