X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/blobdiff_plain/c766c33ca6f63c00cff28b9057b6775c73b8795f..ccf0dd161fca0730b5aa753f0eae6933ea89b489:/tools/__init__.py diff --git a/tools/__init__.py b/tools/__init__.py index cdb5cdd..2afdf42 100644 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -27,19 +27,24 @@ def main(): args.cache = {} args.work = config.defaults["work"] args.config = args.work + "/waydroid.cfg" - args.log = args.work + "/tools.log" + args.log = args.work + "/waydroid.log" args.sudo_timer = True 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) @@ -64,7 +69,7 @@ def main(): actions.container_manager.start(args) elif args.subaction == "stop": actions.container_manager.stop(args) - if args.subaction == "restart": + elif args.subaction == "restart": actions.container_manager.restart(args) elif args.subaction == "freeze": actions.container_manager.freeze(args) @@ -108,8 +113,11 @@ def main(): elif args.action == "log": if args.clear_log: helpers.run.user(args, ["truncate", "-s", "0", args.log]) - helpers.run.user( - args, ["tail", "-n", args.lines, "-F", args.log], output="tui") + try: + helpers.run.user( + args, ["tail", "-n", args.lines, "-F", args.log], output="tui") + except KeyboardInterrupt: + pass else: logging.info("Run waydroid -h for usage information.")