-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_platform.py
More file actions
executable file
·48 lines (38 loc) · 1.15 KB
/
Copy pathcheck_platform.py
File metadata and controls
executable file
·48 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import subprocess
import os
import sys
import json
def get_linux_distro():
out = subprocess.check_output(
'( lsb_release -ds || cat /etc/*release || uname -om ) 2>/dev/null | head -n1',
shell=True,
text=True
)
return out.strip()
def get_desktop_environment():
return os.environ["XDG_CURRENT_DESKTOP"]
def is_platform_supported():
with open("supported_platforms.json") as f:
data = json.load(f)
supported_linux_distributions = data.get("linux_distribution", [])
supported_desktop_environments = data.get("desktop_environment", [])
current_linux_distro = get_linux_distro().lower()
current_de = get_desktop_environment().lower()
linux_distro_supported = any(
ld.lower() in current_linux_distro
for ld in supported_linux_distributions
)
de_supported = any(
de.lower() in current_de
for de in supported_desktop_environments
)
if not de_supported:
print(current_de + " is not supported")
if not linux_distro_supported:
print(current_linux_distro + " is not supported")
return linux_distro_supported and de_supported
if __name__ == "__main__":
if is_platform_supported():
sys.exit(0)
else:
sys.exit(1)