From 6c3a74c5acb0d9b001ff1f1814c7ba7d8fc1f691 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 1 Sep 2020 17:19:50 +0200 Subject: [PATCH] Handle case where the lock doesn't exist : just assume we're the root logger --- src/yunohost/log.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/yunohost/log.py b/src/yunohost/log.py index 20305b2c6..6605d97f6 100644 --- a/src/yunohost/log.py +++ b/src/yunohost/log.py @@ -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: