From 3bc98f855b6b952f9dde02c776c6c16d9d591970 Mon Sep 17 00:00:00 2001 From: douglas-raillard-arm Date: Tue, 23 Mar 2021 11:01:56 +0000 Subject: [PATCH] target: Align Target.background() LC_ALL and PATH Make Target.background() behave like Target.execute(): * Set LC_ALL if force_locale is provided (defaults to "C") * Add the target bin folder to PATH --- devlib/target.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/devlib/target.py b/devlib/target.py index 14f49ba..8f37b0a 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -536,10 +536,7 @@ class Target(object): # execution - def execute(self, command, timeout=None, check_exit_code=True, - as_root=False, strip_colors=True, will_succeed=False, - force_locale='C'): - + def _prepare_cmd(self, command, force_locale): # Force the locale if necessary for more predictable output if force_locale: # Use an explicit export so that the command is allowed to be any @@ -550,11 +547,20 @@ class Target(object): if self.executables_directory: command = "export PATH={}:$PATH && {}".format(quote(self.executables_directory), command) + return command + + def execute(self, command, timeout=None, check_exit_code=True, + as_root=False, strip_colors=True, will_succeed=False, + force_locale='C'): + + command = self._prepare_cmd(command, force_locale) return self.conn.execute(command, timeout=timeout, check_exit_code=check_exit_code, as_root=as_root, strip_colors=strip_colors, will_succeed=will_succeed) - def background(self, command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, as_root=False): + def background(self, command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, as_root=False, + force_locale='C'): + command = self._prepare_cmd(command, force_locale) return self.conn.background(command, stdout, stderr, as_root) def invoke(self, binary, args=None, in_directory=None, on_cpus=None,