tools (common/async_process): remove useless encoding + use full path for command:

- arguments don't need to be encoded anymore, `spawnProcess` handles str directly now
- use full path even for first argument: even if first argument should be only executable
  name, it appears that using full path only in `command` is not enough (seen with Python
  where system installation is used instead of the VirtualEnv one when full path is not
  used as first argument).
This commit is contained in:
Goffi 2021-07-29 22:51:01 +02:00
commit 60fe49f883

View file

@ -114,8 +114,7 @@ class CommandProtocol(protocol.ProcessProtocol):
if stdin is not None:
stdin = stdin.encode('utf-8')
verbose = kwargs.pop('verbose', False)
args = [a.encode('utf-8') for a in args]
kwargs = {k:v.encode('utf-8') for k,v in list(kwargs.items())}
args = list(args)
d = defer.Deferred()
prot = cls(d, stdin=stdin)
if verbose:
@ -131,7 +130,7 @@ class CommandProtocol(protocol.ProcessProtocol):
prot.name = name
else:
command = cls.command
cmd_args = [os.path.basename(command)] + args
cmd_args = [command] + args
reactor.spawnProcess(prot,
command,
cmd_args,