dtelenkov před 1 měsícem
rodič
revize
0e4784cb88

+ 1 - 0
python_net/aioarp/.python-version

@@ -0,0 +1 @@
+3.13

+ 0 - 0
python_net/aioarp/README.md


+ 42 - 0
python_net/aioarp/aioarp/_backends/_utils.py

@@ -0,0 +1,42 @@
+import ipaddress
+import socket
+import subprocess
+import typing
+import getmac
+
+
+__all__ = (
+    'LocalNetwork',
+)
+
+OUR_MAC = None
+OUR_IP = None
+OUR_INTERFACE = None
+
+
+class LocalNetwork:
+    # def get_mac(self, interface: typing.Optional[str]) -> str:
+    #     if interface is None:
+    #         interface = self.
+
+
+    def get_default_interface(self) -> str:
+        global OUR_INTERFACE
+        if OUR_INTERFACE:
+            return OUR_INTERFACE
+        output = subprocess.check_output(['ip', 'route', 'list']).decode().split()
+
+        return 'qwerty'
+
+        for ind, word in enumerate(output):
+            if word == 'dev':
+                OUR_INTERFACE = output[ind + 1]
+                return OUR_INTERFACE
+        raise RuntimeError('Could not find default interface')
+
+
+if __name__ == '__main__':
+    foo = LocalNetwork()
+    print(foo.get_default_interface())
+
+# print(getmac.get_mac_address('Ethernet 3'))

+ 6 - 0
python_net/aioarp/main.py

@@ -0,0 +1,6 @@
+def main():
+    print("Hello from aioarp!")
+
+
+if __name__ == "__main__":
+    main()

+ 9 - 0
python_net/aioarp/pyproject.toml

@@ -0,0 +1,9 @@
+[project]
+name = "aioarp"
+version = "0.1.0"
+description = "Add your description here"
+readme = "README.md"
+requires-python = ">=3.13"
+dependencies = [
+    "getmac>=0.9.5",
+]

+ 1 - 0
python_net/aioarp/requirements.txt

@@ -0,0 +1 @@
+getmac==0.9.5

+ 23 - 0
python_net/aioarp/uv.lock

@@ -0,0 +1,23 @@
+version = 1
+revision = 1
+requires-python = ">=3.13"
+
+[[package]]
+name = "aioarp"
+version = "0.1.0"
+source = { virtual = "." }
+dependencies = [
+    { name = "getmac" },
+]
+
+[package.metadata]
+requires-dist = [{ name = "getmac", specifier = ">=0.9.5" }]
+
+[[package]]
+name = "getmac"
+version = "0.9.5"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/89/a8/4af8e06912cd83b1cc6493e9b5d0589276c858f7bdccaf1855df748983de/getmac-0.9.5.tar.gz", hash = "sha256:456435cdbf1f5f45c433a250b8b795146e893b6fc659060f15451e812a2ab17d", size = 94031 }
+wheels = [
+    { url = "https://files.pythonhosted.org/packages/18/85/4cdbc925381422397bd2b3280680e130091173f2c8dfafb9216eaaa91b00/getmac-0.9.5-py2.py3-none-any.whl", hash = "sha256:22b8a3e15bc0c6bfa94651a3f7f6cd91b59432e1d8199411d4fe12804423e0aa", size = 35781 },
+]

+ 0 - 0
python_net/asyncio/cansel.py → python_net/asyncio_my/cansel.py


+ 0 - 0
python_net/asyncio/debug.py → python_net/asyncio_my/debug.py


+ 9 - 0
python_net/asyncio_my/first_app/misc.py

@@ -0,0 +1,9 @@
+import sys
+print(sys.path)
+sys.path.append('/mnt/e/projects/codewars/python_net/asyncioo')
+print(sys.path)
+
+from util.delay_functions import delay
+
+
+# print(sys.path)

+ 0 - 0
python_net/asyncio/first_app/server.py → python_net/asyncio_my/first_app/server.py


+ 22 - 0
python_net/asyncio_my/first_app/signal_test.py

@@ -0,0 +1,22 @@
+import asyncio, signal
+from asyncio import AbstractEventLoop
+from typing import Set
+import sys
+sys.path.append('/mnt/e/projects/codewars/python_net/asyncioo')
+from util.delay_functions import delay
+
+
+def cansel_tasks():
+    print('Получен сигнал SIGINT!')
+    tasks: Set[asyncio.Task] = asyncio.all_tasks()
+    print(f'Снимается {len(tasks)} задач.')
+    [task.cancel() for task in tasks]
+
+
+async def main():
+    loop: AbstractEventLoop = asyncio.get_running_loop()
+    loop.add_signal_handler(signal.SIGINT, cansel_tasks)
+    await delay(10)
+
+
+asyncio.run(main())

+ 0 - 0
python_net/asyncio/future.py → python_net/asyncio_my/future.py


+ 0 - 0
python_net/asyncio/misc.py → python_net/asyncio_my/misc.py


+ 0 - 0
python_net/asyncio/misc_1.py → python_net/asyncio_my/misc_1.py


+ 0 - 0
python_net/asyncio/util/__init__.py → python_net/asyncio_my/util/__init__.py


+ 0 - 0
python_net/asyncio/util/async_timer.py → python_net/asyncio_my/util/async_timer.py


+ 0 - 0
python_net/asyncio/util/delay_functions.py → python_net/asyncio_my/util/delay_functions.py