Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds@gmail.com>2021-03-23 11:28:52 +0100
committerAnton Hvornum <anton.feeds@gmail.com>2021-03-23 11:28:52 +0100
commitc5f6c4b71263ebfc2a6d840847328b672fd8d5c2 (patch)
treee8cd3e31877460f9947ba7f89b8bd707046b4b56 /archinstall/lib
parent233886f9c5c088e8a8acd84f9d77f3338ae75aef (diff)
Partially corrects for #116. We still don't detect if we're running as root (need to investigate if we need to run as root first). But this should at least hot-swap the log-file to the current working directory and place the logfile there.
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/output.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py
index 0e0a295b..18cbefe0 100644
--- a/archinstall/lib/output.py
+++ b/archinstall/lib/output.py
@@ -96,7 +96,16 @@ def log(*args, **kwargs):
if (filename := storage.get('LOG_FILE', None)):
absolute_logfile = os.path.join(storage.get('LOG_PATH', './'), filename)
if not os.path.isfile(absolute_logfile):
- os.makedirs(os.path.dirname(absolute_logfile))
+ try:
+ os.makedirs(os.path.dirname(absolute_logfile))
+ except PermissionError:
+ # Fallback to creating the log file in the current folder
+ log(f"Not enough permission to place log file at {absolute_logfile}, creating it in {Path('./').absolute()} instead.", fg="red")
+ absolute_logfile = Path('./').absolute()/filename
+ absolute_logfile.makedirs(exist_ok=True)
+ storage['LOG_PATH'] = './'
+
+
Path(absolute_logfile).touch() # Overkill?
with open(absolute_logfile, 'a') as log_file: