mirror of
https://github.com/ARM-software/devlib.git
synced 2025-09-08 21:11:54 +01:00
target: Add Target.execute(force_locale='C') parameter
To avoid locale-specific variations in the output of commands, set LC_ALL=C by default. This can be disabled by using None, or set to another locale.
This commit is contained in:
committed by
Marc Bonnici
parent
ea19235aed
commit
9c86174ff5
@@ -385,10 +385,19 @@ class Target(object):
|
||||
# execution
|
||||
|
||||
def execute(self, command, timeout=None, check_exit_code=True,
|
||||
as_root=False, strip_colors=True, will_succeed=False):
|
||||
as_root=False, strip_colors=True, will_succeed=False,
|
||||
force_locale='C'):
|
||||
|
||||
# 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
|
||||
# shell statement, rather than just a command invocation
|
||||
command = 'export LC_ALL={} && {}'.format(quote(force_locale), command)
|
||||
|
||||
# Ensure to use deployed command when availables
|
||||
if self.executables_directory:
|
||||
command = "PATH={}:$PATH && {}".format(self.executables_directory, command)
|
||||
|
||||
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)
|
||||
|
Reference in New Issue
Block a user