MCPcopy
hub / github.com/flet-dev/flet / is_linux_server

Function is_linux_server

sdk/python/packages/flet/src/flet/utils/platform_utils.py:114–134  ·  view source on GitHub ↗

Indicates whether the current environment is a headless Linux server. The environment is considered a Linux server when: - the host platform is Linux and not mobile; - it is not Windows Subsystem for Linux (WSL); - the `DISPLAY` environment variable is not set. Returns:

()

Source from the content-addressed store, hash-verified

112
113
114def is_linux_server():
115 """
116 Indicates whether the current environment is a headless Linux server.
117
118 The environment is considered a Linux server when:
119 - the host platform is Linux and not mobile;
120 - it is not Windows Subsystem for Linux (WSL);
121 - the `DISPLAY` environment variable is not set.
122
123 Returns:
124 `True` for headless Linux server environments, otherwise `False`.
125 """
126 if not is_mobile() and platform.system() == "Linux":
127 # check if it's WSL
128 p = "/proc/version"
129 if os.path.exists(p):
130 with open(p, encoding="utf-8") as file:
131 if "microsoft" in file.read():
132 return False # it's WSL, not a server
133 return os.environ.get("DISPLAY") is None
134 return False
135
136
137def is_macos():

Callers 1

run_asyncFunction · 0.90

Calls 2

is_mobileFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected