From c4462b699a4e0cc59ff4495e27c7bccd5447dc49 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 12 Feb 2022 15:10:03 +0100 Subject: [PATCH] Added debug information --- archinstall/lib/general.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index d0e9506b..5edac536 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -178,7 +178,7 @@ class SysCommandWorker: def __init__(self, cmd :Union[str, List[str]], callbacks :Optional[Dict[str, Any]] = None, - peak_output :Optional[bool] = False, + peak_output :Optional[bool] = None, environment_vars :Optional[Dict[str, Any]] = None, logfile :Optional[None] = None, working_directory :Optional[str] = './', @@ -201,6 +201,11 @@ class SysCommandWorker: self.cmd = cmd self.callbacks = callbacks + if peak_output is None: + if storage['arguments'].get('debug'): + peak_output = True + else: + peak_output = False self.peak_output = peak_output # define the standard locale for command outputs. For now the C ascii one. Can be overriden self.environment_vars = {**storage.get('CMD_LOCALE',{}),**environment_vars} @@ -368,7 +373,6 @@ class SysCommandWorker: self.started = time.time() self.pid, self.child_fd = pty.fork() - os.chdir(old_dir) # https://stackoverflow.com/questions/4022600/python-pty-fork-how-does-it-work if self.is_child(): @@ -381,6 +385,8 @@ class SysCommandWorker: os.execve(self.cmd[0], list(self.cmd), {**os.environ, **self.environment_vars}) + exit(0) + except FileNotFoundError: with open(f"{storage['LOG_PATH']}/cmd_output.txt", "a") as peak_output_log: peak_output_log(f"[ERROR] {self.cmd[0]} does not exist.") @@ -394,10 +400,12 @@ class SysCommandWorker: exit(1) with open(f"{storage['LOG_PATH']}/cmd_output.txt", "a") as peak_output_log: - peak_output_log(f"[COMPLETED] {self.cmd[0]} has finished.") + peak_output_log.write(f"[COMPLETED] {self.cmd[0]} has finished.") - exit(0) + exit(1) else: + os.chdir(old_dir) + if storage['arguments'].get('debug'): log(f"Executing: {self.cmd}", level=logging.DEBUG)