Move logging code outside of command execution try-except block (#2739)

This commit is contained in:
codefiles 2024-11-04 06:38:58 -05:00 committed by GitHub
parent 8ec1715eb8
commit 481b570dae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 18 deletions

View File

@ -302,7 +302,7 @@ class SysCommandWorker:
# https://stackoverflow.com/questions/4022600/python-pty-fork-how-does-it-work # https://stackoverflow.com/questions/4022600/python-pty-fork-how-does-it-work
if not self.pid: if not self.pid:
history_logfile = pathlib.Path(f"{storage['LOG_PATH']}/cmd_history.txt") history_logfile = pathlib.Path(f"{storage['LOG_PATH']}/cmd_history.txt")
try:
change_perm = False change_perm = False
if history_logfile.exists() is False: if history_logfile.exists() is False:
change_perm = True change_perm = True
@ -324,6 +324,7 @@ class SysCommandWorker:
if storage.get('arguments', {}).get('debug'): if storage.get('arguments', {}).get('debug'):
debug(f"Executing: {self.cmd}") debug(f"Executing: {self.cmd}")
try:
os.execve(self.cmd[0], list(self.cmd), {**os.environ, **self.environment_vars}) os.execve(self.cmd[0], list(self.cmd), {**os.environ, **self.environment_vars})
except FileNotFoundError: except FileNotFoundError:
error(f"{self.cmd[0]} does not exist.") error(f"{self.cmd[0]} does not exist.")