From 154c2cff8b4ad0df443456f847c079a69a6b2264 Mon Sep 17 00:00:00 2001 From: bobokun Date: Thu, 16 Dec 2021 13:21:46 -0500 Subject: [PATCH] add try catch statement for chmod --- qbit_manage.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/qbit_manage.py b/qbit_manage.py index 5697918..54235f3 100644 --- a/qbit_manage.py +++ b/qbit_manage.py @@ -73,10 +73,7 @@ screen_width = get_arg("QBT_WIDTH", args.width, arg_int=True) stats = {} args = {} -if os.path.isdir('/config'): - default_dir = '/config' -else: - default_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config") +default_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config") for v in ['run','sch','config_file','log_file','cross_seed','recheck','cat_update','tag_update','rem_unregistered','rem_orphaned','tag_nohardlinks','skip_recycle','dry_run','log_level','divider','screen_width']: args[v] = eval(v) @@ -130,7 +127,10 @@ file_handler = RotatingFileHandler(file_logger, delay=True, mode="w", maxBytes=m util.apply_formatter(file_handler) file_handler.addFilter(fmt_filter) logger.addHandler(file_handler) -os.chmod(log_path, 0o777) +try: + os.chmod(log_path, 0o777) +except OSError: + pass def start(): start_time = datetime.now() @@ -224,7 +224,6 @@ def start(): def end(): logger.info("Exiting Qbit_manage") - os.chmod(file_logger, 0o777) logger.removeHandler(file_handler) sys.exit(0) @@ -259,8 +258,10 @@ if __name__ == '__main__': logger.debug(f" --divider (QBT_DIVIDER): {divider}") logger.debug(f" --width (QBT_WIDTH): {screen_width}") logger.debug("") - - os.chmod(file_logger, 0o777) + try: + os.chmod(file_logger, 0o777) + except OSError: + pass try: if run: logger.info(f" Run Mode: Script will exit after completion.")