From f589750a3cff6f061bc4b78ef857e52a7fbc874c Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 14 Mar 2021 12:16:46 +0100 Subject: Tweaked SysCallError() exception to include the exit code in a machine readable manner. Since it's useful as an indicator where calls might go wrong and for what reason. --- archinstall/lib/general.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/general.py') diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index e87e4102..28fc0934 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -251,7 +251,7 @@ class sys_command():#Thread): if self.exit_code != 0 and not self.kwargs['suppress_errors']: #self.log(self.trace_log.decode('UTF-8'), level=LOG_LEVELS.Debug) #self.log(f"'{self.raw_cmd}' did not exit gracefully, exit code {self.exit_code}.", level=LOG_LEVELS.Error) - raise SysCallError(f"{self.trace_log.decode('UTF-8')}\n'{self.raw_cmd}' did not exit gracefully (trace log above), exit code: {self.exit_code}") + raise SysCallError(message=f"{self.trace_log.decode('UTF-8')}\n'{self.raw_cmd}' did not exit gracefully (trace log above), exit code: {self.exit_code}", exit_code=self.exit_code) self.ended = time.time() with open(f'{self.cwd}/trace.log', 'wb') as fh: -- cgit v1.2.3-70-g09d2 From b672efdf6b5951e53fa3548cc06cd1c319f82217 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 23 Mar 2021 14:18:03 +0100 Subject: Enabling archinstall.sys_command() to get a working directory when executing. The sys_command() is working pretty well for this very specific need, but this is an attempt to making it a bit more generic. A more general overhaul of the command should be done at some point. --- archinstall/lib/general.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'archinstall/lib/general.py') diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 28fc0934..d79bbaa2 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -106,7 +106,11 @@ class sys_command():#Thread): user_catalogue = os.path.expanduser('~') self.cwd = f"{user_catalogue}/.cache/archinstall/workers/{kwargs['worker_id']}/" - self.exec_dir = f'{self.cwd}/{os.path.basename(self.cmd[0])}_workingdir' + + if (workdir := kwargs.get('workdir', None)): + self.exec_dir = workdir + else: + self.exec_dir = f'{self.cwd}/{os.path.basename(self.cmd[0])}_workingdir' if not self.cmd[0][0] == '/': # "which" doesn't work as it's a builtin to bash. -- cgit v1.2.3-70-g09d2 From becd29fa54beaced554f6cf54d44706192ea9a9c Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 23 Mar 2021 14:22:38 +0100 Subject: Also setting cwd (bad choice of name) to the workdir if one was specified. Which makes the trace.log to end up in the workdir as well. --- archinstall/lib/general.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'archinstall/lib/general.py') diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index d79bbaa2..f2a714e7 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -105,11 +105,12 @@ class sys_command():#Thread): self.status = 'starting' user_catalogue = os.path.expanduser('~') - self.cwd = f"{user_catalogue}/.cache/archinstall/workers/{kwargs['worker_id']}/" if (workdir := kwargs.get('workdir', None)): + self.cwd = workdir self.exec_dir = workdir else: + self.cwd = f"{user_catalogue}/.cache/archinstall/workers/{kwargs['worker_id']}/" self.exec_dir = f'{self.cwd}/{os.path.basename(self.cmd[0])}_workingdir' if not self.cmd[0][0] == '/': -- cgit v1.2.3-70-g09d2