()
| 12 | |
| 13 | @lru_cache(maxsize=1) |
| 14 | def get_ip() -> str: |
| 15 | try: |
| 16 | # try to get ip from network interface |
| 17 | with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: |
| 18 | s.connect(("8.8.8.8", 80)) |
| 19 | return s.getsockname()[0] |
| 20 | except Exception as e: # noqa: BLE001 |
| 21 | # fallback to get ip from hostname |
| 22 | logger.warning( |
| 23 | f"fail to get ip from network interface, fallback to get ip from hostname: {e}" |
| 24 | ) |
| 25 | return socket.gethostbyname(socket.gethostname()) |
| 26 | |
| 27 | |
| 28 | def npu_generate_uuid() -> str: |
no outgoing calls
no test coverage detected