From a948982700e3192d7bb00f67e886f35146cc34a9 Mon Sep 17 00:00:00 2001 From: douglas-raillard-arm Date: Wed, 18 Nov 2020 17:04:00 +0000 Subject: [PATCH] host: Fix string literal String literals are concatenated automatically in Python: assert 'a' 'b' == 'ab' This means that adding ' ' in the middle of a literal delimited by ' will be a no-op. Fix that by changing the literal delimiter to ". --- devlib/host.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devlib/host.py b/devlib/host.py index be2a30f..e214ce6 100644 --- a/devlib/host.py +++ b/devlib/host.py @@ -101,7 +101,7 @@ class LocalConnection(ConnectionBase): if self.unrooted: raise TargetStableError('unrooted') password = self._get_password() - command = 'echo {} | sudo -p ' ' -S -- sh -c '.format(quote(password)) + quote(command) + command = "echo {} | sudo -p ' ' -S -- sh -c ".format(quote(password)) + quote(command) ignore = None if check_exit_code else 'all' try: stdout, stderr = check_output(command, shell=True, timeout=timeout, ignore=ignore) @@ -119,7 +119,7 @@ class LocalConnection(ConnectionBase): if self.unrooted: raise TargetStableError('unrooted') password = self._get_password() - command = 'echo {} | sudo -p ' ' -S '.format(quote(password)) + command + command = "echo {} | sudo -p ' ' -S ".format(quote(password)) + command # Make sure to get a new PGID so PopenBackgroundCommand() can kill # all sub processes that could be started without troubles.