Fixing permission error on non-root-runners accessing log()

This commit is contained in:
Anton Hvornum 2021-04-28 14:20:12 +02:00
parent 58d933e150
commit a13db6bffd
1 changed files with 2 additions and 0 deletions

View File

@ -110,6 +110,8 @@ def log(*args, **kwargs):
if not os.path.isfile(absolute_logfile):
try:
Path(absolute_logfile).parents[0].mkdir(exist_ok=True, parents=True)
with open(absolute_logfile, 'a') as log_file:
log_file.write("")
except PermissionError:
# Fallback to creating the log file in the current folder
err_string = f"Not enough permission to place log file at {absolute_logfile}, creating it in {Path('./').absolute()/filename} instead."