Handle case where the lock doesn't exist : just assume we're the root logger

This commit is contained in:
Alexandre Aubin 2020-09-01 17:19:50 +02:00
parent 63ff02be50
commit 6c3a74c5ac

View file

@ -384,6 +384,12 @@ class OperationLogger(object):
# We are a child of the first one we found
return instance.name
# If no lock exists, we are probably in tests or yunohost is used as a
# lib ... let's not really care about that case and assume we're the
# root logger then.
if not os.path.exists("/var/run/moulinette_yunohost.lock"):
return None
locks = read_file("/var/run/moulinette_yunohost.lock").strip().split("\n")
# If we're the process with the lock, we're the root logger
if locks == [] or str(os.getpid()) in locks: