Like this and you most also activate stdout,stderr pipes.
Now you decode
This is a very old way of doing string formatting.
From 3.6 use
Now you decode
out.decode()
is the same as out.decode('utf-8')
def run_process(cmd_args): with subprocess.Popen(cmd_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: out, err = p.communicate() return outIf also want to return err
return out,err
,then it become a Tuple and you use res[0].decode()
. This is a very old way of doing string formatting.
From 3.6 use
f-string
. f.write('Process Output : %s\n' % (res.decode("utf-8"))). # To f.write(f'Process Output: {res.decode()}\n')