[+] add interfaces_index
This commit is contained in:
parent
202bf85f55
commit
799280f074
@ -1,5 +1,7 @@
|
|||||||
import shutil
|
import shutil
|
||||||
import glob
|
import glob
|
||||||
|
import subprocess
|
||||||
|
import pydantic
|
||||||
import pathlib
|
import pathlib
|
||||||
import ctypes
|
import ctypes
|
||||||
import os
|
import os
|
||||||
@ -93,9 +95,9 @@ def runtime_libdirs_init(
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
class interfaces_index_t:
|
class interfaces_index_t:
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass
|
||||||
class Interface:
|
class Interface:
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass
|
||||||
class AddrInfo:
|
class AddrInfo:
|
||||||
family: str
|
family: str
|
||||||
local: str
|
local: str
|
||||||
@ -103,32 +105,13 @@ class interfaces_index_t:
|
|||||||
name: str
|
name: str
|
||||||
addr_info: list[AddrInfo]
|
addr_info: list[AddrInfo]
|
||||||
|
|
||||||
def interfaces_index() -> list[Interfaces]:
|
def interfaces_index() -> list[interfaces_index_t.Interface]:
|
||||||
ip_addr_res: Any = json.loads(
|
res = pydantic.RootModel[
|
||||||
|
list[interfaces_index_t.Interface]
|
||||||
|
].model_validate_json(
|
||||||
subprocess.check_output([
|
subprocess.check_output([
|
||||||
'ip', '-j', 'addr',
|
'ip', '-j', 'addr',
|
||||||
]).decode('utf-8')
|
]).decode('utf-8')
|
||||||
)
|
).root
|
||||||
|
|
||||||
assert isinstance(ip_addr_res, list)
|
return res
|
||||||
|
|
||||||
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:
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = 'online.fxreader.pr34'
|
name = 'online.fxreader.pr34'
|
||||||
version = '0.1.5.9'
|
version = '0.1.5.9+27.1'
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
#"-r requirements.txt",
|
#"-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