add try catch statement for chmod

This commit is contained in:
bobokun 2021-12-16 13:21:46 -05:00
parent 3acabcc09d
commit 154c2cff8b
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671

View file

@ -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.")