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@hvornum.se>2021-11-18 21:18:41 +0000
committerGitHub <noreply@github.com>2021-11-18 22:18:41 +0100
commit5ec690da939ff5b2efb3ba2ffe177cb035c25ee6 (patch)
treebab9e3ba915654a87dd72441d4f75a9c3d4fd3e9 /archinstall/lib
parent4e3d2cff0cfa640b87d9c674bfc0ec65d8b147cd (diff)
Adding a cmd_history.txt log under /var/log/archinstall/ (#737)
* Adding a cmd_history.txt log under /var/log/archinstall/ to get a clear picture of which commands was executed.
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/disk/helpers.py11
-rw-r--r--archinstall/lib/general.py7
2 files changed, 16 insertions, 2 deletions
diff --git a/archinstall/lib/disk/helpers.py b/archinstall/lib/disk/helpers.py
index e15e69b2..fea9ef65 100644
--- a/archinstall/lib/disk/helpers.py
+++ b/archinstall/lib/disk/helpers.py
@@ -182,9 +182,16 @@ def get_filesystem_type(path):
def disk_layouts():
try:
- return json.loads(SysCommand("lsblk -f -o+TYPE,SIZE -J").decode('UTF-8'))
+ if (handle := SysCommand("lsblk -f -o+TYPE,SIZE -J")).exit_code == 0:
+ return json.loads(handle.decode('UTF-8'))
+ else:
+ log(f"Could not return disk layouts: {handle}", level=logging.WARNING, fg="yellow")
+ return None
except SysCallError as err:
- log(f"Could not return disk layouts: {err}")
+ log(f"Could not return disk layouts: {err}", level=logging.WARNING, fg="yellow")
+ return None
+ except json.decoder.JSONDecodeError as err:
+ log(f"Could not return disk layouts: {err}", level=logging.WARNING, fg="yellow")
return None
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index f3773755..ee088d4f 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -308,9 +308,16 @@ class SysCommandWorker:
if not self.pid:
try:
+ try:
+ with open(f"{storage['LOG_PATH']}/cmd_history.txt", "a") as cmd_log:
+ cmd_log.write(f"{' '.join(self.cmd)}\n")
+ except PermissionError:
+ pass
+
os.execve(self.cmd[0], self.cmd, {**os.environ, **self.environment_vars})
if storage['arguments'].get('debug'):
log(f"Executing: {self.cmd}", level=logging.DEBUG)
+
except FileNotFoundError:
log(f"{self.cmd[0]} does not exist.", level=logging.ERROR, fg="red")
self.exit_code = 1