Corrected error handling for log creation.
This commit is contained in:
parent
09cab32749
commit
04804e6edc
|
|
@ -23,3 +23,4 @@ SAFETY_LOCK
|
||||||
**/test.py
|
**/test.py
|
||||||
**/archiso
|
**/archiso
|
||||||
/guided.py
|
/guided.py
|
||||||
|
/install.log
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ def log(*args, **kwargs):
|
||||||
# we use that one to output everything
|
# we use that one to output everything
|
||||||
if (filename := storage.get('LOG_FILE', None)):
|
if (filename := storage.get('LOG_FILE', None)):
|
||||||
absolute_logfile = os.path.join(storage.get('LOG_PATH', './'), filename)
|
absolute_logfile = os.path.join(storage.get('LOG_PATH', './'), filename)
|
||||||
if not os.path.isfile(absolute_logfile):
|
|
||||||
try:
|
try:
|
||||||
Path(absolute_logfile).parents[0].mkdir(exist_ok=True, parents=True)
|
Path(absolute_logfile).parents[0].mkdir(exist_ok=True, parents=True)
|
||||||
with open(absolute_logfile, 'a') as log_file:
|
with open(absolute_logfile, 'a') as log_file:
|
||||||
|
|
@ -121,12 +121,9 @@ def log(*args, **kwargs):
|
||||||
storage['LOG_PATH'] = './'
|
storage['LOG_PATH'] = './'
|
||||||
log(err_string, fg="red")
|
log(err_string, fg="red")
|
||||||
|
|
||||||
Path(absolute_logfile).touch() # Overkill?
|
|
||||||
|
|
||||||
with open(absolute_logfile, 'a') as log_file:
|
with open(absolute_logfile, 'a') as log_file:
|
||||||
log_file.write(f"{orig_string}\n")
|
log_file.write(f"{orig_string}\n")
|
||||||
|
|
||||||
|
|
||||||
# If we assigned a level, try to log it to systemd's journald.
|
# If we assigned a level, try to log it to systemd's journald.
|
||||||
# Unless the level is higher than we've decided to output interactively.
|
# Unless the level is higher than we've decided to output interactively.
|
||||||
# (Remember, log files still get *ALL* the output despite level restrictions)
|
# (Remember, log files still get *ALL* the output despite level restrictions)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue