Loading src/pygarden/system/__init__.py 0 → 100644 +5 −0 Original line number Diff line number Diff line try: import psutil except ImportError: import loguru loguru.logger.error("psutil not installed, please install pygarden with the 'system' extra") src/pygarden/system/ports.py 0 → 100644 +22 −0 Original line number Diff line number Diff line import psutil def get_used_ports(): """ Get the ports that are currently in use on the system. """ used_ports = set() for conn in psutil.net_connections(kind='inet'): if conn.laddr: used_ports.add(conn.laddr.port) return sorted(used_ports) if __name__ == "__main__": from pygarden.logz import create_logger l = create_logger() used_ports = get_used_ports() l.info("Used ports:") l.info("\n".join(map(str, used_ports)) if used_ports else "No ports in use") src/pyproject.toml +4 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,9 @@ cli = [ minio = [ "minio~=7.1.0" ] system = [ "psutil~=6.1.1", ] all = [ "psycopg2-binary==2.9.9", "pymssql==2.2.11", Loading @@ -79,6 +82,7 @@ all = [ "rich==13.7.1", "click==8.0.3", "minio~=7.1.0", "psutil~=6.1.1", ] dev = [ "ruff==0.5.4", Loading Loading
src/pygarden/system/__init__.py 0 → 100644 +5 −0 Original line number Diff line number Diff line try: import psutil except ImportError: import loguru loguru.logger.error("psutil not installed, please install pygarden with the 'system' extra")
src/pygarden/system/ports.py 0 → 100644 +22 −0 Original line number Diff line number Diff line import psutil def get_used_ports(): """ Get the ports that are currently in use on the system. """ used_ports = set() for conn in psutil.net_connections(kind='inet'): if conn.laddr: used_ports.add(conn.laddr.port) return sorted(used_ports) if __name__ == "__main__": from pygarden.logz import create_logger l = create_logger() used_ports = get_used_ports() l.info("Used ports:") l.info("\n".join(map(str, used_ports)) if used_ports else "No ports in use")
src/pyproject.toml +4 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,9 @@ cli = [ minio = [ "minio~=7.1.0" ] system = [ "psutil~=6.1.1", ] all = [ "psycopg2-binary==2.9.9", "pymssql==2.2.11", Loading @@ -79,6 +82,7 @@ all = [ "rich==13.7.1", "click==8.0.3", "minio~=7.1.0", "psutil~=6.1.1", ] dev = [ "ruff==0.5.4", Loading