Unify string formatting

Use one way of string formatting: replace old `%` style with new `str.format`.

Resolve #855.
This commit is contained in:
Darko Poljak 2021-03-30 07:56:38 +02:00
commit 4c2d273f07
17 changed files with 67 additions and 65 deletions

View file

@ -24,12 +24,10 @@ import os
import glob
import subprocess
import logging
import multiprocessing
import cdist
import cdist.exec.util as util
import cdist.util.ipaddr as ipaddr
from cdist.mputil import mp_pool_run
def _wrap_addr(addr):
@ -262,9 +260,10 @@ class Remote:
# remotely in e.g. csh and setting up CDIST_REMOTE_SHELL to e.g.
# /bin/csh will execute this script in the right way.
if env:
remote_env = [" export %s=%s;" % item for item in env.items()]
string_cmd = ("/bin/sh -c '" + " ".join(remote_env) +
" ".join(command) + "'")
remote_env = [" export {env[0]}={env[1]};".format(env=item)
for item in env.items()]
string_cmd = ("/bin/sh -c '{}{}'").format(" ".join(remote_env),
" ".join(command))
cmd.append(string_cmd)
else:
cmd.extend(command)
@ -278,7 +277,7 @@ class Remote:
"""
assert isinstance(command, (list, tuple)), (
"list or tuple argument expected, got: %s" % command)
"list or tuple argument expected, got: {}".format(command))
close_stdout = False
close_stderr = False