def on_cluster(pattern=["tars-"]):
"""Used to check if we are on a cluster
"tars-" is the name of a cluster's hostname.
Change or append the argument **pattern** with your cluster's hostname
:param str pattern: a list of names (strings) or a string
"""
if isinstance(pattern, str):
pattern = [pattern]
for this in pattern:
if platform.uname().node.startswith(this):
return True
else:
return False
评论列表
文章目录