comparison sat/tools/common/async_process.py @ 3603:25cbaf047728

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).
author Goffi <goffi@goffi.org>
date Thu, 29 Jul 2021 22:51:01 +0200
parents 04283582966f
children 799d4f6fa7ca
comparison
equal deleted inserted replaced
3602:7241ce3b79dd 3603:25cbaf047728
112 """ 112 """
113 stdin = kwargs.pop('stdin', None) 113 stdin = kwargs.pop('stdin', None)
114 if stdin is not None: 114 if stdin is not None:
115 stdin = stdin.encode('utf-8') 115 stdin = stdin.encode('utf-8')
116 verbose = kwargs.pop('verbose', False) 116 verbose = kwargs.pop('verbose', False)
117 args = [a.encode('utf-8') for a in args] 117 args = list(args)
118 kwargs = {k:v.encode('utf-8') for k,v in list(kwargs.items())}
119 d = defer.Deferred() 118 d = defer.Deferred()
120 prot = cls(d, stdin=stdin) 119 prot = cls(d, stdin=stdin)
121 if verbose: 120 if verbose:
122 prot.log = True 121 prot.log = True
123 if cls.command is None: 122 if cls.command is None:
129 if prot.name is None: 128 if prot.name is None:
130 name = os.path.splitext(os.path.basename(command))[0] 129 name = os.path.splitext(os.path.basename(command))[0]
131 prot.name = name 130 prot.name = name
132 else: 131 else:
133 command = cls.command 132 command = cls.command
134 cmd_args = [os.path.basename(command)] + args 133 cmd_args = [command] + args
135 reactor.spawnProcess(prot, 134 reactor.spawnProcess(prot,
136 command, 135 command,
137 cmd_args, 136 cmd_args,
138 **kwargs) 137 **kwargs)
139 return d 138 return d