From e4b0643fb5ab70a1a01c48a3c6208e38228e4613 Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Sat, 2 Oct 2021 10:54:11 +0100 Subject: [PATCH] log: More resilient logging --- tools/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/__init__.py b/tools/__init__.py index 7c948d4..2afdf42 100644 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -32,14 +32,19 @@ def main(): args.timeout = 1800 if not os.path.isfile(args.config): - if args.action and args.action != "init": + if args.action and (args.action != "init" and args.action != "log"): print('ERROR: WayDroid is not initialized, run "waydroid init"') return 0 elif os.geteuid() == 0 and args.action == "init": if not os.path.exists(args.work): os.mkdir(args.work) else: - args.log = "/tmp/tools.log" + # This branch is taken if: + # - waydroid is not yet initialized + # - waydroid is invoked with no command or with log + if not os.path.exists(args.log): + # The log could have been already created if init was used and failed, if its not the case we use a temporary one + args.log = "/tmp/tools.log" tools_logging.init(args) -- 2.47.3