import os import sys import platform import socket from utils.network import get_local_ip def resource_path(relative_path): """ Get absolute path to resource, works for dev and for PyInstaller """ try: base_path = sys._MEIPASS except Exception: base_path = os.path.abspath(".") return os.path.join(base_path, relative_path) def get_machine_info(): """Collect machine info.""" hostname = socket.gethostname() local_ip = get_local_ip() os_info = f"{platform.system()} {platform.release()}" mac_addr = "N/A" try: import uuid mac = uuid.getnode() mac_addr = ":".join( f"{(mac >> (8 * i)) & 0xFF:02X}" for i in reversed(range(6)) ) except Exception: pass return { "hostname": hostname, "ip": local_ip, "os": os_info, "mac": mac_addr, } def get_version(): """Read version from version.txt""" try: with open(resource_path('version.txt'), 'r', encoding='utf-8') as f: return f.read().strip() except Exception: return "Unknown"