2024-03-29 21:48:06 +01:00
|
|
|
import platform
|
|
|
|
|
|
|
|
|
2024-03-31 22:20:47 +02:00
|
|
|
def get_hostname():
|
2024-03-29 21:48:06 +01:00
|
|
|
hostname = platform.node()
|
|
|
|
if hostname.count("."):
|
|
|
|
hostname = hostname.split(".")[0]
|
|
|
|
return hostname
|
|
|
|
|
|
|
|
|
2024-03-31 22:20:47 +02:00
|
|
|
def get_arch():
|
|
|
|
return platform.system()
|
|
|
|
|
|
|
|
|
|
|
|
def check_class(class_tuple):
|
|
|
|
(prio, category, value, path) = class_tuple
|
|
|
|
if category == 'Arch':
|
|
|
|
return get_arch() == value
|
|
|
|
elif category == 'Host':
|
|
|
|
return get_hostname() == value
|
|
|
|
elif value == '': # if value is empty, we cannot filter anything, so it matches always
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|