mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Run pyupgrade
on the files changed on the merge forward
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
22107ebd32
commit
ad4821b87f
22 changed files with 172 additions and 189 deletions
|
@ -109,9 +109,9 @@ DFLT_LOG_FMT_LOGFILE = "%(asctime)s,%(msecs)03d [%(name)-17s:%(lineno)-4d][%(lev
|
|||
class SaltLogRecord(logging.LogRecord):
|
||||
def __init__(self, *args, **kwargs):
|
||||
logging.LogRecord.__init__(self, *args, **kwargs)
|
||||
self.bracketname = "[{:<17}]".format(str(self.name))
|
||||
self.bracketlevel = "[{:<8}]".format(str(self.levelname))
|
||||
self.bracketprocess = "[{:>5}]".format(str(self.process))
|
||||
self.bracketname = f"[{str(self.name):<17}]"
|
||||
self.bracketlevel = f"[{str(self.levelname):<8}]"
|
||||
self.bracketprocess = f"[{str(self.process):>5}]"
|
||||
|
||||
|
||||
class SaltColorLogRecord(SaltLogRecord):
|
||||
|
@ -125,11 +125,11 @@ class SaltColorLogRecord(SaltLogRecord):
|
|||
self.colorname = "{}[{:<17}]{}".format(
|
||||
LOG_COLORS["name"], str(self.name), reset
|
||||
)
|
||||
self.colorlevel = "{}[{:<8}]{}".format(clevel, str(self.levelname), reset)
|
||||
self.colorlevel = f"{clevel}[{str(self.levelname):<8}]{reset}"
|
||||
self.colorprocess = "{}[{:>5}]{}".format(
|
||||
LOG_COLORS["process"], str(self.process), reset
|
||||
)
|
||||
self.colormsg = "{}{}{}".format(cmsg, self.getMessage(), reset)
|
||||
self.colormsg = f"{cmsg}{self.getMessage()}{reset}"
|
||||
|
||||
|
||||
def get_log_record_factory():
|
||||
|
@ -275,27 +275,16 @@ class SaltLoggingClass(LOGGING_LOGGER_CLASS, metaclass=LoggingMixinMeta):
|
|||
else:
|
||||
extra["exc_info_on_loglevel"] = exc_info_on_loglevel
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
LOGGING_LOGGER_CLASS._log(
|
||||
self,
|
||||
level,
|
||||
msg,
|
||||
args,
|
||||
exc_info=exc_info,
|
||||
extra=extra,
|
||||
stack_info=stack_info,
|
||||
)
|
||||
else:
|
||||
LOGGING_LOGGER_CLASS._log(
|
||||
self,
|
||||
level,
|
||||
msg,
|
||||
args,
|
||||
exc_info=exc_info,
|
||||
extra=extra,
|
||||
stack_info=stack_info,
|
||||
stacklevel=stacklevel,
|
||||
)
|
||||
LOGGING_LOGGER_CLASS._log(
|
||||
self,
|
||||
level,
|
||||
msg,
|
||||
args,
|
||||
exc_info=exc_info,
|
||||
extra=extra,
|
||||
stack_info=stack_info,
|
||||
stacklevel=stacklevel,
|
||||
)
|
||||
|
||||
def makeRecord(
|
||||
self,
|
||||
|
@ -738,7 +727,7 @@ def setup_logfile_handler(
|
|||
syslog_opts["address"] = str(path.resolve().parent)
|
||||
except OSError as exc:
|
||||
raise LoggingRuntimeError(
|
||||
"Failed to setup the Syslog logging handler: {}".format(exc)
|
||||
f"Failed to setup the Syslog logging handler: {exc}"
|
||||
) from exc
|
||||
elif parsed_log_path.path:
|
||||
# In case of udp or tcp with a facility specified
|
||||
|
@ -748,7 +737,7 @@ def setup_logfile_handler(
|
|||
# Logging facilities start with LOG_ if this is not the case
|
||||
# fail right now!
|
||||
raise LoggingRuntimeError(
|
||||
"The syslog facility '{}' is not known".format(facility_name)
|
||||
f"The syslog facility '{facility_name}' is not known"
|
||||
)
|
||||
else:
|
||||
# This is the case of udp or tcp without a facility specified
|
||||
|
@ -759,7 +748,7 @@ def setup_logfile_handler(
|
|||
# This python syslog version does not know about the user provided
|
||||
# facility name
|
||||
raise LoggingRuntimeError(
|
||||
"The syslog facility '{}' is not known".format(facility_name)
|
||||
f"The syslog facility '{facility_name}' is not known"
|
||||
)
|
||||
syslog_opts["facility"] = facility
|
||||
|
||||
|
@ -779,7 +768,7 @@ def setup_logfile_handler(
|
|||
handler = SysLogHandler(**syslog_opts)
|
||||
except OSError as exc:
|
||||
raise LoggingRuntimeError(
|
||||
"Failed to setup the Syslog logging handler: {}".format(exc)
|
||||
f"Failed to setup the Syslog logging handler: {exc}"
|
||||
) from exc
|
||||
else:
|
||||
# make sure, the logging directory exists and attempt to create it if necessary
|
||||
|
|
|
@ -74,7 +74,7 @@ class Beacon:
|
|||
|
||||
# Run the validate function if it's available,
|
||||
# otherwise there is a warning about it being missing
|
||||
validate_str = "{}.validate".format(beacon_name)
|
||||
validate_str = f"{beacon_name}.validate"
|
||||
if validate_str in self.beacons:
|
||||
valid, vcomment = self.beacons[validate_str](b_config[mod])
|
||||
|
||||
|
@ -95,7 +95,7 @@ class Beacon:
|
|||
continue
|
||||
|
||||
b_config[mod].append({"_beacon_name": mod})
|
||||
fun_str = "{}.beacon".format(beacon_name)
|
||||
fun_str = f"{beacon_name}.beacon"
|
||||
if fun_str in self.beacons:
|
||||
runonce = self._determine_beacon_config(
|
||||
current_beacon_config, "run_once"
|
||||
|
@ -124,7 +124,7 @@ class Beacon:
|
|||
if re.match("state.*", job["fun"]):
|
||||
is_running = True
|
||||
if is_running:
|
||||
close_str = "{}.close".format(beacon_name)
|
||||
close_str = f"{beacon_name}.close"
|
||||
if close_str in self.beacons:
|
||||
log.info("Closing beacon %s. State run in progress.", mod)
|
||||
self.beacons[close_str](b_config[mod])
|
||||
|
@ -139,7 +139,7 @@ class Beacon:
|
|||
try:
|
||||
raw = self.beacons[fun_str](b_config[mod])
|
||||
except: # pylint: disable=bare-except
|
||||
error = "{}".format(sys.exc_info()[1])
|
||||
error = f"{sys.exc_info()[1]}"
|
||||
log.error("Unable to start %s beacon, %s", mod, error)
|
||||
# send beacon error event
|
||||
tag = "salt/beacon/{}/{}/".format(self.opts["id"], mod)
|
||||
|
@ -308,7 +308,7 @@ class Beacon:
|
|||
"""
|
||||
beacon_name = next(item.get("beacon_module", name) for item in beacon_data)
|
||||
|
||||
validate_str = "{}.validate".format(beacon_name)
|
||||
validate_str = f"{beacon_name}.validate"
|
||||
# Run the validate function if it's available,
|
||||
# otherwise there is a warning about it being missing
|
||||
if validate_str in self.beacons:
|
||||
|
@ -347,9 +347,9 @@ class Beacon:
|
|||
complete = False
|
||||
else:
|
||||
if name in self.opts["beacons"]:
|
||||
comment = "Updating settings for beacon item: {}".format(name)
|
||||
comment = f"Updating settings for beacon item: {name}"
|
||||
else:
|
||||
comment = "Added new beacon item: {}".format(name)
|
||||
comment = f"Added new beacon item: {name}"
|
||||
complete = True
|
||||
self.opts["beacons"].update(data)
|
||||
|
||||
|
@ -375,12 +375,10 @@ class Beacon:
|
|||
data[name] = beacon_data
|
||||
|
||||
if name in self._get_beacons(include_opts=False):
|
||||
comment = (
|
||||
"Cannot modify beacon item {}, it is configured in pillar.".format(name)
|
||||
)
|
||||
comment = f"Cannot modify beacon item {name}, it is configured in pillar."
|
||||
complete = False
|
||||
else:
|
||||
comment = "Updating settings for beacon item: {}".format(name)
|
||||
comment = f"Updating settings for beacon item: {name}"
|
||||
complete = True
|
||||
self.opts["beacons"].update(data)
|
||||
|
||||
|
@ -402,16 +400,14 @@ class Beacon:
|
|||
"""
|
||||
|
||||
if name in self._get_beacons(include_opts=False):
|
||||
comment = (
|
||||
"Cannot delete beacon item {}, it is configured in pillar.".format(name)
|
||||
)
|
||||
comment = f"Cannot delete beacon item {name}, it is configured in pillar."
|
||||
complete = False
|
||||
else:
|
||||
if name in self.opts["beacons"]:
|
||||
del self.opts["beacons"][name]
|
||||
comment = "Deleting beacon item: {}".format(name)
|
||||
comment = f"Deleting beacon item: {name}"
|
||||
else:
|
||||
comment = "Beacon item {} not found.".format(name)
|
||||
comment = f"Beacon item {name} not found."
|
||||
complete = True
|
||||
|
||||
# Fire the complete event back along with updated list of beacons
|
||||
|
@ -465,13 +461,11 @@ class Beacon:
|
|||
"""
|
||||
|
||||
if name in self._get_beacons(include_opts=False):
|
||||
comment = (
|
||||
"Cannot enable beacon item {}, it is configured in pillar.".format(name)
|
||||
)
|
||||
comment = f"Cannot enable beacon item {name}, it is configured in pillar."
|
||||
complete = False
|
||||
else:
|
||||
self._update_enabled(name, True)
|
||||
comment = "Enabling beacon item {}".format(name)
|
||||
comment = f"Enabling beacon item {name}"
|
||||
complete = True
|
||||
|
||||
# Fire the complete event back along with updated list of beacons
|
||||
|
@ -501,7 +495,7 @@ class Beacon:
|
|||
complete = False
|
||||
else:
|
||||
self._update_enabled(name, False)
|
||||
comment = "Disabling beacon item {}".format(name)
|
||||
comment = f"Disabling beacon item {name}"
|
||||
complete = True
|
||||
|
||||
# Fire the complete event back along with updated list of beacons
|
||||
|
|
|
@ -134,7 +134,7 @@ class ReqServerChannel:
|
|||
raise tornado.gen.Return("bad load: id contains a null byte")
|
||||
except TypeError:
|
||||
log.error("Payload contains non-string id: %s", payload)
|
||||
raise tornado.gen.Return("bad load: id {} is not a string".format(id_))
|
||||
raise tornado.gen.Return(f"bad load: id {id_} is not a string")
|
||||
|
||||
version = 0
|
||||
if "version" in payload:
|
||||
|
|
|
@ -122,8 +122,8 @@ def gen_keys(keydir, keyname, keysize, user=None, passphrase=None):
|
|||
:return: Path on the filesystem to the RSA private key
|
||||
"""
|
||||
base = os.path.join(keydir, keyname)
|
||||
priv = "{}.pem".format(base)
|
||||
pub = "{}.pub".format(base)
|
||||
priv = f"{base}.pem"
|
||||
pub = f"{base}.pub"
|
||||
|
||||
if HAS_M2:
|
||||
gen = RSA.gen_key(keysize, 65537, lambda: None)
|
||||
|
@ -443,7 +443,7 @@ class MasterKeys(dict):
|
|||
try:
|
||||
key = get_rsa_key(path, passphrase)
|
||||
except key_error as e:
|
||||
message = "Unable to read key: {}; passphrase may be incorrect".format(path)
|
||||
message = f"Unable to read key: {path}; passphrase may be incorrect"
|
||||
log.error(message)
|
||||
raise MasterExit(message)
|
||||
log.debug("Loaded %s key: %s", name, path)
|
||||
|
|
|
@ -538,7 +538,7 @@ def safe_accept(target, tgt_type="glob"):
|
|||
del ret[minion]
|
||||
continue
|
||||
elif minion not in pending:
|
||||
failures[minion] = "Minion key {} not found by salt-key".format(minion)
|
||||
failures[minion] = f"Minion key {minion} not found by salt-key"
|
||||
elif pending[minion] != finger:
|
||||
failures[
|
||||
minion
|
||||
|
@ -560,7 +560,8 @@ def safe_accept(target, tgt_type="glob"):
|
|||
print("")
|
||||
|
||||
__jid_event__.fire_event(
|
||||
{"message": "Accepted {:d} keys".format(len(ret))}, "progress"
|
||||
{"message": f"Accepted {len(ret):d} keys"},
|
||||
"progress",
|
||||
)
|
||||
return ret, failures
|
||||
|
||||
|
@ -730,8 +731,8 @@ def bootstrap(
|
|||
client_opts["argv"] = [
|
||||
"http.query",
|
||||
script,
|
||||
"backend={}".format(http_backend),
|
||||
"text_out={}".format(deploy_command),
|
||||
f"backend={http_backend}",
|
||||
f"text_out={deploy_command}",
|
||||
]
|
||||
salt.client.ssh.SSH(client_opts).run()
|
||||
client_opts["argv"] = [
|
||||
|
@ -846,7 +847,7 @@ objShell.Exec("{1}{2}")"""
|
|||
vb_saltexec = "saltinstall.exe"
|
||||
vb_saltexec_args = " /S /minion-name=%COMPUTERNAME%"
|
||||
if master:
|
||||
vb_saltexec_args += " /master={}".format(master)
|
||||
vb_saltexec_args += f" /master={master}"
|
||||
|
||||
# One further thing we need to do; the Windows Salt minion is pretty
|
||||
# self-contained, except for the Microsoft Visual C++ 2008 runtime.
|
||||
|
|
|
@ -414,7 +414,7 @@ def salt_key():
|
|||
_install_signal_handlers(client)
|
||||
client.run()
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
sys.stderr.write("Error: {}\n".format(err))
|
||||
sys.stderr.write(f"Error: {err}\n")
|
||||
|
||||
|
||||
def salt_cp():
|
||||
|
@ -572,7 +572,7 @@ def salt_unity():
|
|||
if len(sys.argv) < 2:
|
||||
msg = "Must pass in a salt command, available commands are:"
|
||||
for cmd in avail:
|
||||
msg += "\n{}".format(cmd)
|
||||
msg += f"\n{cmd}"
|
||||
print(msg)
|
||||
sys.exit(1)
|
||||
cmd = sys.argv[1]
|
||||
|
@ -581,9 +581,9 @@ def salt_unity():
|
|||
sys.argv[0] = "salt"
|
||||
s_fun = salt_main
|
||||
else:
|
||||
sys.argv[0] = "salt-{}".format(cmd)
|
||||
sys.argv[0] = f"salt-{cmd}"
|
||||
sys.argv.pop(1)
|
||||
s_fun = getattr(sys.modules[__name__], "salt_{}".format(cmd))
|
||||
s_fun = getattr(sys.modules[__name__], f"salt_{cmd}")
|
||||
s_fun()
|
||||
|
||||
|
||||
|
|
|
@ -158,8 +158,8 @@ def _clean_tag(tag):
|
|||
|
||||
def _l_tag(name, id_):
|
||||
low = {
|
||||
"name": "listen_{}".format(name),
|
||||
"__id__": "listen_{}".format(id_),
|
||||
"name": f"listen_{name}",
|
||||
"__id__": f"listen_{id_}",
|
||||
"state": "Listen_Error",
|
||||
"fun": "Listen_Error",
|
||||
}
|
||||
|
@ -1065,7 +1065,7 @@ class State:
|
|||
return ret
|
||||
elif isinstance(entry, dict):
|
||||
if "fun" not in entry:
|
||||
ret["comment"] = "no `fun` argument in onlyif: {}".format(entry)
|
||||
ret["comment"] = f"no `fun` argument in onlyif: {entry}"
|
||||
log.warning(ret["comment"])
|
||||
return ret
|
||||
|
||||
|
@ -1143,7 +1143,7 @@ class State:
|
|||
return ret
|
||||
elif isinstance(entry, dict):
|
||||
if "fun" not in entry:
|
||||
ret["comment"] = "no `fun` argument in unless: {}".format(entry)
|
||||
ret["comment"] = f"no `fun` argument in unless: {entry}"
|
||||
log.warning(ret["comment"])
|
||||
return ret
|
||||
|
||||
|
@ -1393,9 +1393,9 @@ class State:
|
|||
)
|
||||
reason = self.states.missing_fun_string(full)
|
||||
if reason:
|
||||
errors.append("Reason: {}".format(reason))
|
||||
errors.append(f"Reason: {reason}")
|
||||
else:
|
||||
errors.append("Specified state '{}' was not found".format(full))
|
||||
errors.append(f"Specified state '{full}' was not found")
|
||||
else:
|
||||
# First verify that the parameters are met
|
||||
aspec = salt.utils.args.get_function_argspec(self.states[full])
|
||||
|
@ -2122,7 +2122,7 @@ class State:
|
|||
"result": False,
|
||||
"name": name,
|
||||
"changes": {},
|
||||
"comment": "An exception occurred in this state: {}".format(trb),
|
||||
"comment": f"An exception occurred in this state: {trb}",
|
||||
}
|
||||
|
||||
utc_finish_time = datetime.datetime.utcnow()
|
||||
|
@ -2228,7 +2228,7 @@ class State:
|
|||
proc = salt.utils.process.Process(
|
||||
target=self._call_parallel_target,
|
||||
args=(instance, self._init_kwargs, name, cdata, low),
|
||||
name="ParallelState({})".format(name),
|
||||
name=f"ParallelState({name})",
|
||||
)
|
||||
proc.start()
|
||||
ret = {
|
||||
|
@ -2264,7 +2264,7 @@ class State:
|
|||
"comment": "",
|
||||
}
|
||||
for err in errors:
|
||||
ret["comment"] += "{}\n".format(err)
|
||||
ret["comment"] += f"{err}\n"
|
||||
ret["__run_num__"] = self.__run_num
|
||||
self.__run_num += 1
|
||||
format_log(ret)
|
||||
|
@ -2411,7 +2411,7 @@ class State:
|
|||
"result": False,
|
||||
"name": name,
|
||||
"changes": {},
|
||||
"comment": "An exception occurred in this state: {}".format(trb),
|
||||
"comment": f"An exception occurred in this state: {trb}",
|
||||
}
|
||||
finally:
|
||||
if low.get("__prereq__"):
|
||||
|
@ -3423,7 +3423,7 @@ class State:
|
|||
lkey, lval
|
||||
)
|
||||
),
|
||||
"name": "listen_{}:{}".format(lkey, lval),
|
||||
"name": f"listen_{lkey}:{lval}",
|
||||
"result": False,
|
||||
"changes": {},
|
||||
}
|
||||
|
@ -3538,9 +3538,7 @@ class State:
|
|||
return high, errors
|
||||
|
||||
if not isinstance(high, dict):
|
||||
errors.append(
|
||||
"Template {} does not render to a dictionary".format(template)
|
||||
)
|
||||
errors.append(f"Template {template} does not render to a dictionary")
|
||||
return high, errors
|
||||
|
||||
invalid_items = ("include", "exclude", "extends")
|
||||
|
@ -3915,10 +3913,10 @@ class BaseHighState:
|
|||
"""
|
||||
merging_strategy = self.opts["top_file_merging_strategy"]
|
||||
try:
|
||||
merge_attr = "_merge_tops_{}".format(merging_strategy)
|
||||
merge_attr = f"_merge_tops_{merging_strategy}"
|
||||
merge_func = getattr(self, merge_attr)
|
||||
if not hasattr(merge_func, "__call__"):
|
||||
msg = "'{}' is not callable".format(merge_attr)
|
||||
msg = f"'{merge_attr}' is not callable"
|
||||
log.error(msg)
|
||||
raise TypeError(msg)
|
||||
except (AttributeError, TypeError):
|
||||
|
@ -4246,7 +4244,7 @@ class BaseHighState:
|
|||
fn_ = sls
|
||||
if not os.path.isfile(fn_):
|
||||
errors.append(
|
||||
"Specified SLS {} on local filesystem cannot be found.".format(sls)
|
||||
f"Specified SLS {sls} on local filesystem cannot be found."
|
||||
)
|
||||
state = None
|
||||
if not fn_:
|
||||
|
@ -4269,25 +4267,25 @@ class BaseHighState:
|
|||
context=context,
|
||||
)
|
||||
except SaltRenderError as exc:
|
||||
msg = "Rendering SLS '{}:{}' failed: {}".format(saltenv, sls, exc)
|
||||
msg = f"Rendering SLS '{saltenv}:{sls}' failed: {exc}"
|
||||
log.critical(msg)
|
||||
errors.append(msg)
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
msg = "Rendering SLS {} failed, render error: {}".format(sls, exc)
|
||||
msg = f"Rendering SLS {sls} failed, render error: {exc}"
|
||||
log.critical(
|
||||
msg,
|
||||
# Show the traceback if the debug logging level is enabled
|
||||
exc_info_on_loglevel=logging.DEBUG,
|
||||
)
|
||||
errors.append("{}\n{}".format(msg, traceback.format_exc()))
|
||||
errors.append(f"{msg}\n{traceback.format_exc()}")
|
||||
try:
|
||||
mods.add("{}:{}".format(saltenv, sls))
|
||||
mods.add(f"{saltenv}:{sls}")
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
if state:
|
||||
if not isinstance(state, dict):
|
||||
errors.append("SLS {} does not render to a dictionary".format(sls))
|
||||
errors.append(f"SLS {sls} does not render to a dictionary")
|
||||
else:
|
||||
include = []
|
||||
if "include" in state:
|
||||
|
@ -4390,7 +4388,7 @@ class BaseHighState:
|
|||
r_env = (
|
||||
resolved_envs[0] if len(resolved_envs) == 1 else saltenv
|
||||
)
|
||||
mod_tgt = "{}:{}".format(r_env, sls_target)
|
||||
mod_tgt = f"{r_env}:{sls_target}"
|
||||
if mod_tgt not in mods:
|
||||
nstate, err = self.render_state(
|
||||
sls_target,
|
||||
|
@ -4490,7 +4488,7 @@ class BaseHighState:
|
|||
comps[0]: [comps[1]],
|
||||
}
|
||||
continue
|
||||
errors.append("ID {} in SLS {} is not a dictionary".format(name, sls))
|
||||
errors.append(f"ID {name} in SLS {sls} is not a dictionary")
|
||||
continue
|
||||
skeys = set()
|
||||
for key in list(state[name]):
|
||||
|
@ -4534,9 +4532,7 @@ class BaseHighState:
|
|||
if "extend" in state:
|
||||
ext = state.pop("extend")
|
||||
if not isinstance(ext, dict):
|
||||
errors.append(
|
||||
"Extension value in SLS '{}' is not a dictionary".format(sls)
|
||||
)
|
||||
errors.append(f"Extension value in SLS '{sls}' is not a dictionary")
|
||||
return
|
||||
for name in ext:
|
||||
if not isinstance(ext[name], dict):
|
||||
|
@ -4603,7 +4599,7 @@ class BaseHighState:
|
|||
statefiles = [sls_match]
|
||||
|
||||
for sls in statefiles:
|
||||
r_env = "{}:{}".format(saltenv, sls)
|
||||
r_env = f"{saltenv}:{sls}"
|
||||
if r_env in mods:
|
||||
continue
|
||||
state, errors = self.render_state(
|
||||
|
@ -4614,7 +4610,7 @@ class BaseHighState:
|
|||
for i, error in enumerate(errors[:]):
|
||||
if "is not available" in error:
|
||||
# match SLS foobar in environment
|
||||
this_sls = "SLS {} in saltenv".format(sls_match)
|
||||
this_sls = f"SLS {sls_match} in saltenv"
|
||||
if this_sls in error:
|
||||
errors[
|
||||
i
|
||||
|
@ -4659,7 +4655,7 @@ class BaseHighState:
|
|||
try:
|
||||
highstate.update(state)
|
||||
except ValueError:
|
||||
errors.append("Error when rendering state with contents: {}".format(state))
|
||||
errors.append(f"Error when rendering state with contents: {state}")
|
||||
|
||||
def _check_pillar(self, force=False):
|
||||
"""
|
||||
|
@ -4712,7 +4708,7 @@ class BaseHighState:
|
|||
"__run_num__": 0,
|
||||
}
|
||||
}
|
||||
cfn = os.path.join(self.opts["cachedir"], "{}.cache.p".format(cache_name))
|
||||
cfn = os.path.join(self.opts["cachedir"], f"{cache_name}.cache.p")
|
||||
|
||||
if cache:
|
||||
if os.path.isfile(cfn):
|
||||
|
|
|
@ -90,7 +90,7 @@ def publish_server(opts, **kwargs):
|
|||
import salt.transport.local
|
||||
|
||||
return salt.transport.local.LocalPubServerChannel(opts, **kwargs)
|
||||
raise Exception("Transport type not found: {}".format(ttype))
|
||||
raise Exception(f"Transport type not found: {ttype}")
|
||||
|
||||
|
||||
def publish_client(opts, io_loop, host=None, port=None, path=None, transport=None):
|
||||
|
@ -118,7 +118,7 @@ def publish_client(opts, io_loop, host=None, port=None, path=None, transport=Non
|
|||
opts, io_loop, host=host, port=port, path=path
|
||||
)
|
||||
|
||||
raise Exception("Transport type not found: {}".format(ttype))
|
||||
raise Exception(f"Transport type not found: {ttype}")
|
||||
|
||||
|
||||
def _minion_hash(hash_type, minion_id):
|
||||
|
@ -154,9 +154,7 @@ def ipc_publish_client(node, opts, io_loop):
|
|||
minion_id=opts.get("hash_id", opts["id"]),
|
||||
)
|
||||
kwargs.update(
|
||||
path=os.path.join(
|
||||
opts["sock_dir"], "minion_event_{}_pub.ipc".format(id_hash)
|
||||
)
|
||||
path=os.path.join(opts["sock_dir"], f"minion_event_{id_hash}_pub.ipc")
|
||||
)
|
||||
return publish_client(opts, io_loop, **kwargs)
|
||||
|
||||
|
@ -190,13 +188,11 @@ def ipc_publish_server(node, opts):
|
|||
hash_type=opts["hash_type"],
|
||||
minion_id=opts.get("hash_id", opts["id"]),
|
||||
)
|
||||
pub_path = os.path.join(
|
||||
opts["sock_dir"], "minion_event_{}_pub.ipc".format(id_hash)
|
||||
)
|
||||
pub_path = os.path.join(opts["sock_dir"], f"minion_event_{id_hash}_pub.ipc")
|
||||
kwargs.update(
|
||||
pub_path=pub_path,
|
||||
pull_path=os.path.join(
|
||||
opts["sock_dir"], "minion_event_{}_pull.ipc".format(id_hash)
|
||||
opts["sock_dir"], f"minion_event_{id_hash}_pull.ipc"
|
||||
),
|
||||
)
|
||||
return publish_server(opts, **kwargs)
|
||||
|
|
|
@ -92,7 +92,7 @@ class SyncWrapper:
|
|||
self._async_methods += self.obj._coroutines
|
||||
|
||||
def __repr__(self):
|
||||
return "<SyncWrapper(cls={})".format(self.cls)
|
||||
return f"<SyncWrapper(cls={self.cls})"
|
||||
|
||||
def close(self):
|
||||
for method in self._close_methods:
|
||||
|
|
|
@ -427,7 +427,7 @@ class SaltEvent:
|
|||
def _get_match_func(self, match_type=None):
|
||||
if match_type is None:
|
||||
match_type = self.opts["event_match_type"]
|
||||
return getattr(self, "_match_tag_{}".format(match_type), None)
|
||||
return getattr(self, f"_match_tag_{match_type}", None)
|
||||
|
||||
def _check_pending(self, tag, match_func=None):
|
||||
"""Check the pending_events list for events that match the tag
|
||||
|
@ -702,7 +702,7 @@ class SaltEvent:
|
|||
raise ValueError("Empty tag.")
|
||||
|
||||
if not isinstance(data, MutableMapping): # data must be dict
|
||||
raise ValueError("Dict object expected, not '{}'.".format(data))
|
||||
raise ValueError(f"Dict object expected, not '{data}'.")
|
||||
|
||||
if not self.cpush:
|
||||
if timeout is not None:
|
||||
|
@ -763,7 +763,7 @@ class SaltEvent:
|
|||
raise ValueError("Empty tag.")
|
||||
|
||||
if not isinstance(data, MutableMapping): # data must be dict
|
||||
raise ValueError("Dict object expected, not '{}'.".format(data))
|
||||
raise ValueError(f"Dict object expected, not '{data}'.")
|
||||
|
||||
if not self.cpush:
|
||||
if timeout is not None:
|
||||
|
@ -863,13 +863,11 @@ class SaltEvent:
|
|||
data["retcode"] = retcode
|
||||
tags = tag.split("_|-")
|
||||
if data.get("result") is False:
|
||||
self.fire_event(
|
||||
data, "{}.{}".format(tags[0], tags[-1])
|
||||
) # old dup event
|
||||
self.fire_event(data, f"{tags[0]}.{tags[-1]}") # old dup event
|
||||
data["jid"] = load["jid"]
|
||||
data["id"] = load["id"]
|
||||
data["success"] = False
|
||||
data["return"] = "Error: {}.{}".format(tags[0], tags[-1])
|
||||
data["return"] = f"Error: {tags[0]}.{tags[-1]}"
|
||||
data["fun"] = fun
|
||||
data["user"] = load["user"]
|
||||
self.fire_event(
|
||||
|
@ -1053,12 +1051,12 @@ class AsyncEventPublisher:
|
|||
salt.utils.stringutils.to_bytes(self.opts["id"])
|
||||
).hexdigest()[:10]
|
||||
epub_sock_path = os.path.join(
|
||||
self.opts["sock_dir"], "minion_event_{}_pub.ipc".format(id_hash)
|
||||
self.opts["sock_dir"], f"minion_event_{id_hash}_pub.ipc"
|
||||
)
|
||||
if os.path.exists(epub_sock_path):
|
||||
os.unlink(epub_sock_path)
|
||||
epull_sock_path = os.path.join(
|
||||
self.opts["sock_dir"], "minion_event_{}_pull.ipc".format(id_hash)
|
||||
self.opts["sock_dir"], f"minion_event_{id_hash}_pull.ipc"
|
||||
)
|
||||
if os.path.exists(epull_sock_path):
|
||||
os.unlink(epull_sock_path)
|
||||
|
@ -1278,7 +1276,7 @@ class EventReturn(salt.utils.process.SignalHandlingProcess):
|
|||
# Multiple event returners
|
||||
for r in self.opts["event_return"]:
|
||||
log.debug("Calling event returner %s, one of many.", r)
|
||||
event_return = "{}.event_return".format(r)
|
||||
event_return = f"{r}.event_return"
|
||||
self._flush_event_single(event_return)
|
||||
else:
|
||||
# Only a single event returner
|
||||
|
|
|
@ -672,7 +672,7 @@ def cidr_to_ipv4_netmask(cidr_bits):
|
|||
netmask += "255"
|
||||
cidr_bits -= 8
|
||||
else:
|
||||
netmask += "{:d}".format(256 - (2 ** (8 - cidr_bits)))
|
||||
netmask += f"{256 - (2 ** (8 - cidr_bits)):d}"
|
||||
cidr_bits = 0
|
||||
return netmask
|
||||
|
||||
|
@ -839,11 +839,7 @@ def _interfaces_ifconfig(out):
|
|||
if salt.utils.platform.is_sunos():
|
||||
expand_mac = []
|
||||
for chunk in data["hwaddr"].split(":"):
|
||||
expand_mac.append(
|
||||
"0{}".format(chunk)
|
||||
if len(chunk) < 2
|
||||
else "{}".format(chunk)
|
||||
)
|
||||
expand_mac.append(f"0{chunk}" if len(chunk) < 2 else f"{chunk}")
|
||||
data["hwaddr"] = ":".join(expand_mac)
|
||||
if mip:
|
||||
if "inet" not in data:
|
||||
|
@ -1187,7 +1183,7 @@ def get_net_start(ipaddr, netmask):
|
|||
"""
|
||||
Return the address of the network
|
||||
"""
|
||||
net = ipaddress.ip_network("{}/{}".format(ipaddr, netmask), strict=False)
|
||||
net = ipaddress.ip_network(f"{ipaddr}/{netmask}", strict=False)
|
||||
return str(net.network_address)
|
||||
|
||||
|
||||
|
@ -1209,7 +1205,7 @@ def calc_net(ipaddr, netmask=None):
|
|||
(The IP can be any IP inside the subnet)
|
||||
"""
|
||||
if netmask is not None:
|
||||
ipaddr = "{}/{}".format(ipaddr, netmask)
|
||||
ipaddr = f"{ipaddr}/{netmask}"
|
||||
|
||||
return str(ipaddress.ip_network(ipaddr, strict=False))
|
||||
|
||||
|
@ -1480,7 +1476,7 @@ def _ip_networks(
|
|||
_net = addr.get("netmask" if proto == "inet" else "prefixlen")
|
||||
if _ip and _net:
|
||||
try:
|
||||
ip_net = ipaddress.ip_network("{}/{}".format(_ip, _net), strict=False)
|
||||
ip_net = ipaddress.ip_network(f"{_ip}/{_net}", strict=False)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
continue
|
||||
if not ip_net.is_loopback or include_loopback:
|
||||
|
@ -1589,8 +1585,8 @@ def mac2eui64(mac, prefix=None):
|
|||
else:
|
||||
try:
|
||||
net = ipaddress.ip_network(prefix, strict=False)
|
||||
euil = int("0x{}".format(eui64), 16)
|
||||
return "{}/{}".format(net[euil], net.prefixlen)
|
||||
euil = int(f"0x{eui64}", 16)
|
||||
return f"{net[euil]}/{net.prefixlen}"
|
||||
except Exception: # pylint: disable=broad-except
|
||||
return
|
||||
|
||||
|
@ -1716,7 +1712,7 @@ def _netlink_tool_remote_on(port, which_end):
|
|||
tcp_end = "dst" if which_end == "remote_port" else "src"
|
||||
try:
|
||||
data = subprocess.check_output(
|
||||
["ss", "-ant", tcp_end, ":{}".format(port)]
|
||||
["ss", "-ant", tcp_end, f":{port}"]
|
||||
) # pylint: disable=minimum-python-version
|
||||
except subprocess.CalledProcessError:
|
||||
log.error("Failed ss")
|
||||
|
@ -1810,7 +1806,7 @@ def _freebsd_remotes_on(port, which_end):
|
|||
remotes = set()
|
||||
|
||||
try:
|
||||
cmd = salt.utils.args.shlex_split("sockstat -4 -c -p {}".format(port))
|
||||
cmd = salt.utils.args.shlex_split(f"sockstat -4 -c -p {port}")
|
||||
data = subprocess.check_output(cmd) # pylint: disable=minimum-python-version
|
||||
except subprocess.CalledProcessError as ex:
|
||||
log.error('Failed "sockstat" with returncode = %s', ex.returncode)
|
||||
|
@ -1872,7 +1868,7 @@ def _netbsd_remotes_on(port, which_end):
|
|||
remotes = set()
|
||||
|
||||
try:
|
||||
cmd = salt.utils.args.shlex_split("sockstat -4 -c -n -p {}".format(port))
|
||||
cmd = salt.utils.args.shlex_split(f"sockstat -4 -c -n -p {port}")
|
||||
data = subprocess.check_output(cmd) # pylint: disable=minimum-python-version
|
||||
except subprocess.CalledProcessError as ex:
|
||||
log.error('Failed "sockstat" with returncode = %s', ex.returncode)
|
||||
|
@ -2014,7 +2010,7 @@ def _linux_remotes_on(port, which_end):
|
|||
data = subprocess.check_output(
|
||||
[
|
||||
lsof_binary,
|
||||
"-iTCP:{:d}".format(port),
|
||||
f"-iTCP:{port:d}",
|
||||
"-n",
|
||||
"-P",
|
||||
] # pylint: disable=minimum-python-version
|
||||
|
@ -2219,7 +2215,7 @@ def dns_check(addr, port, safe=False, ipv6=None):
|
|||
error = True
|
||||
|
||||
if not ip_addrs:
|
||||
err = "DNS lookup or connection check of '{}' failed.".format(addr)
|
||||
err = f"DNS lookup or connection check of '{addr}' failed."
|
||||
if safe:
|
||||
log.error(err)
|
||||
raise SaltClientError()
|
||||
|
@ -2284,9 +2280,7 @@ def parse_host_port(host_port):
|
|||
port = int(_s_.lstrip(":"))
|
||||
else:
|
||||
if len(_s_) > 1:
|
||||
raise ValueError(
|
||||
'found ambiguous "{}" port in "{}"'.format(_s_, host_port)
|
||||
)
|
||||
raise ValueError(f'found ambiguous "{_s_}" port in "{host_port}"')
|
||||
else:
|
||||
if _s_.count(":") == 1:
|
||||
host, _hostport_separator_, port = _s_.partition(":")
|
||||
|
@ -2308,7 +2302,7 @@ def parse_host_port(host_port):
|
|||
log.debug('"%s" Not an IP address? Assuming it is a hostname.', host)
|
||||
if host != sanitize_host(host):
|
||||
log.error('bad hostname: "%s"', host)
|
||||
raise ValueError('bad hostname: "{}"'.format(host))
|
||||
raise ValueError(f'bad hostname: "{host}"')
|
||||
|
||||
return host, port
|
||||
|
||||
|
@ -2339,7 +2333,7 @@ def filter_by_networks(values, networks):
|
|||
elif isinstance(values, Sequence):
|
||||
return _filter(values, networks)
|
||||
else:
|
||||
raise ValueError("Do not know how to filter a {}".format(type(values)))
|
||||
raise ValueError(f"Do not know how to filter a {type(values)}")
|
||||
else:
|
||||
return values
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ def salt_master_factory(
|
|||
"redundant_minions": "N@min or N@mins",
|
||||
"nodegroup_loop_a": "N@nodegroup_loop_b",
|
||||
"nodegroup_loop_b": "N@nodegroup_loop_a",
|
||||
"missing_minion": "L@{},ghostminion".format(salt_minion_id),
|
||||
"missing_minion": f"L@{salt_minion_id},ghostminion",
|
||||
"list_group": "N@multiline_nodegroup",
|
||||
"one_list_group": "N@one_minion_list",
|
||||
"list_group2": "N@list_nodegroup",
|
||||
|
@ -176,7 +176,7 @@ def salt_master_factory(
|
|||
"etcd.port": sdb_etcd_port,
|
||||
}
|
||||
config_defaults["vault"] = {
|
||||
"url": "http://127.0.0.1:{}".format(vault_port),
|
||||
"url": f"http://127.0.0.1:{vault_port}",
|
||||
"auth": {"method": "token", "token": "testsecret", "uses": 0},
|
||||
"policies": ["testpolicy"],
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ def salt_master_factory(
|
|||
config_overrides["external_auth"] = {
|
||||
"pam": {
|
||||
salt_auth_account_1_factory.username: ["test.*"],
|
||||
"{}%".format(salt_auth_account_2_factory.group_name): [
|
||||
f"{salt_auth_account_2_factory.group_name}%": [
|
||||
"@wheel",
|
||||
"@runner",
|
||||
"test.*",
|
||||
|
@ -308,7 +308,7 @@ def salt_minion_factory(salt_master_factory, salt_minion_id, sdb_etcd_port, vaul
|
|||
"etcd.port": sdb_etcd_port,
|
||||
}
|
||||
config_defaults["vault"] = {
|
||||
"url": "http://127.0.0.1:{}".format(vault_port),
|
||||
"url": f"http://127.0.0.1:{vault_port}",
|
||||
"auth": {"method": "token", "token": "testsecret", "uses": 0},
|
||||
"policies": ["testpolicy"],
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ def tmp_path_world_rw(request):
|
|||
Temporary path which is world read/write for tests that run under a different account
|
||||
"""
|
||||
tempdir_path = pathlib.Path(basetemp=tempfile.gettempdir()).resolve()
|
||||
path = tempdir_path / "world-rw-{}".format(id(request.node))
|
||||
path = tempdir_path / f"world-rw-{id(request.node)}"
|
||||
path.mkdir(exist_ok=True)
|
||||
path.chmod(0o777)
|
||||
try:
|
||||
|
|
|
@ -50,7 +50,7 @@ def root_dir(tmp_path):
|
|||
|
||||
|
||||
def transport_ids(value):
|
||||
return "transport({})".format(value)
|
||||
return f"transport({value})"
|
||||
|
||||
|
||||
@pytest.fixture(params=["tcp", "zeromq"], ids=transport_ids)
|
||||
|
|
|
@ -140,7 +140,7 @@ class MockSubscriber:
|
|||
},
|
||||
use_bin_type=True,
|
||||
)
|
||||
tag = "salt/job/{}/ret".format(jid).encode()
|
||||
tag = f"salt/job/{jid}/ret".encode()
|
||||
return b"".join([tag, b"\n\n", dumped])
|
||||
|
||||
def connect(self, timeout=None):
|
||||
|
|
|
@ -104,7 +104,7 @@ def test_issue_36469_tcp(salt_master, salt_minion, transport):
|
|||
load = {
|
||||
"tgt_type": "glob",
|
||||
"tgt": "*",
|
||||
"jid": "{}-s{}".format(sid, idx),
|
||||
"jid": f"{sid}-s{idx}",
|
||||
}
|
||||
await server_channel.publish(load)
|
||||
|
||||
|
@ -125,7 +125,7 @@ def test_issue_36469_tcp(salt_master, salt_minion, transport):
|
|||
load = {
|
||||
"tgt_type": "glob",
|
||||
"tgt": "*",
|
||||
"jid": "{}-l{}".format(sid, idx),
|
||||
"jid": f"{sid}-l{idx}",
|
||||
"xdata": "0" * size,
|
||||
}
|
||||
await server_channel.publish(load)
|
||||
|
@ -146,8 +146,8 @@ def test_issue_36469_tcp(salt_master, salt_minion, transport):
|
|||
executor.submit(_send_large, opts, 2)
|
||||
executor.submit(_send_small, opts, 3)
|
||||
executor.submit(_send_large, opts, 4)
|
||||
expect.extend(["{}-s{}".format(a, b) for a in range(10) for b in (1, 3)])
|
||||
expect.extend(["{}-l{}".format(a, b) for a in range(10) for b in (2, 4)])
|
||||
expect.extend([f"{a}-s{b}" for a in range(10) for b in (1, 3)])
|
||||
expect.extend([f"{a}-l{b}" for a in range(10) for b in (2, 4)])
|
||||
results = server_channel.collector.results
|
||||
assert len(results) == send_num, "{} != {}, difference: {}".format(
|
||||
len(results), send_num, set(expect).difference(results)
|
||||
|
|
|
@ -25,9 +25,7 @@ def test_reauth(salt_master_factory, event_listener):
|
|||
"test_reauth-master",
|
||||
overrides={"log_level": "info"},
|
||||
)
|
||||
sls_tempfile = master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
)
|
||||
sls_tempfile = master.state_tree.base.temp_file(f"{sls_name}.sls", sls_contents)
|
||||
minion = master.salt_minion_daemon(
|
||||
"test_reauth-minion",
|
||||
overrides={"log_level": "info"},
|
||||
|
|
|
@ -22,7 +22,7 @@ def test_minion_hangs_on_master_failure_50814(
|
|||
event_count = 3
|
||||
while True:
|
||||
check_event_start_time = time.time()
|
||||
event_tag = "myco/foo/bar/{}".format(event_count)
|
||||
event_tag = f"myco/foo/bar/{event_count}"
|
||||
ret = mm_master_2_salt_cli.run(
|
||||
"event.send", event_tag, minion_tgt=salt_mm_minion_1.id
|
||||
)
|
||||
|
@ -69,7 +69,7 @@ def test_minion_hangs_on_master_failure_50814(
|
|||
event_count = 1
|
||||
while True:
|
||||
check_event_start_time = time.time()
|
||||
event_tag = "myco/foo/bar/{}".format(event_count)
|
||||
event_tag = f"myco/foo/bar/{event_count}"
|
||||
ret = mm_master_2_salt_cli.run(
|
||||
"event.send", event_tag, minion_tgt=salt_mm_minion_1.id
|
||||
)
|
||||
|
|
|
@ -275,36 +275,53 @@ def test_master_uri():
|
|||
"salt.transport.zeromq.ZMQ_VERSION_INFO", (16, 0, 1)
|
||||
):
|
||||
# pass in both source_ip and source_port
|
||||
assert salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip, master_port=m_port, source_ip=s_ip, source_port=s_port
|
||||
) == "tcp://{}:{};{}:{}".format(s_ip, s_port, m_ip, m_port)
|
||||
assert (
|
||||
salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip, master_port=m_port, source_ip=s_ip, source_port=s_port
|
||||
)
|
||||
== f"tcp://{s_ip}:{s_port};{m_ip}:{m_port}"
|
||||
)
|
||||
|
||||
assert salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip6, master_port=m_port, source_ip=s_ip6, source_port=s_port
|
||||
) == "tcp://[{}]:{};[{}]:{}".format(s_ip6, s_port, m_ip6, m_port)
|
||||
assert (
|
||||
salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip6, master_port=m_port, source_ip=s_ip6, source_port=s_port
|
||||
)
|
||||
== f"tcp://[{s_ip6}]:{s_port};[{m_ip6}]:{m_port}"
|
||||
)
|
||||
|
||||
# source ip and source_port empty
|
||||
assert salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip, master_port=m_port
|
||||
) == "tcp://{}:{}".format(m_ip, m_port)
|
||||
assert (
|
||||
salt.transport.zeromq._get_master_uri(master_ip=m_ip, master_port=m_port)
|
||||
== f"tcp://{m_ip}:{m_port}"
|
||||
)
|
||||
|
||||
assert salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip6, master_port=m_port
|
||||
) == "tcp://[{}]:{}".format(m_ip6, m_port)
|
||||
assert (
|
||||
salt.transport.zeromq._get_master_uri(master_ip=m_ip6, master_port=m_port)
|
||||
== f"tcp://[{m_ip6}]:{m_port}"
|
||||
)
|
||||
|
||||
# pass in only source_ip
|
||||
assert salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip, master_port=m_port, source_ip=s_ip
|
||||
) == "tcp://{}:0;{}:{}".format(s_ip, m_ip, m_port)
|
||||
assert (
|
||||
salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip, master_port=m_port, source_ip=s_ip
|
||||
)
|
||||
== f"tcp://{s_ip}:0;{m_ip}:{m_port}"
|
||||
)
|
||||
|
||||
assert salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip6, master_port=m_port, source_ip=s_ip6
|
||||
) == "tcp://[{}]:0;[{}]:{}".format(s_ip6, m_ip6, m_port)
|
||||
assert (
|
||||
salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip6, master_port=m_port, source_ip=s_ip6
|
||||
)
|
||||
== f"tcp://[{s_ip6}]:0;[{m_ip6}]:{m_port}"
|
||||
)
|
||||
|
||||
# pass in only source_port
|
||||
assert salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip, master_port=m_port, source_port=s_port
|
||||
) == "tcp://0.0.0.0:{};{}:{}".format(s_port, m_ip, m_port)
|
||||
assert (
|
||||
salt.transport.zeromq._get_master_uri(
|
||||
master_ip=m_ip, master_port=m_port, source_port=s_port
|
||||
)
|
||||
== f"tcp://0.0.0.0:{s_port};{m_ip}:{m_port}"
|
||||
)
|
||||
|
||||
|
||||
def test_clear_req_channel_master_uri_override(temp_salt_minion, temp_salt_master):
|
||||
|
|
|
@ -23,7 +23,7 @@ pytestmark = [
|
|||
|
||||
|
||||
def transport_ids(value):
|
||||
return "Transport({})".format(value)
|
||||
return f"Transport({value})"
|
||||
|
||||
|
||||
@pytest.fixture(params=("zeromq", "tcp"), ids=transport_ids)
|
||||
|
|
|
@ -55,7 +55,7 @@ def test_provider_case_insensitive_gitfs_provider(minion_opts, role_name, role_c
|
|||
Ensure that both lowercase and non-lowercase values are supported
|
||||
"""
|
||||
provider = "GitPython"
|
||||
key = "{}_provider".format(role_name)
|
||||
key = f"{role_name}_provider"
|
||||
with patch.object(role_class, "verify_gitpython", MagicMock(return_value=True)):
|
||||
with patch.object(role_class, "verify_pygit2", MagicMock(return_value=False)):
|
||||
args = [minion_opts, {}]
|
||||
|
@ -93,7 +93,7 @@ def test_valid_provider_gitfs_provider(minion_opts, role_name, role_class):
|
|||
"""
|
||||
return MagicMock(return_value=verify.endswith(provider))
|
||||
|
||||
key = "{}_provider".format(role_name)
|
||||
key = f"{role_name}_provider"
|
||||
for provider in salt.utils.gitfs.GIT_PROVIDERS:
|
||||
verify = "verify_gitpython"
|
||||
mock1 = _get_mock(verify, provider)
|
||||
|
|
|
@ -74,7 +74,7 @@ def no_symlinks():
|
|||
ret = subprocess.run(
|
||||
["git", "config", "--get", "core.symlinks"],
|
||||
shell=False,
|
||||
universal_newlines=True,
|
||||
text=True,
|
||||
cwd=RUNTIME_VARS.CODE_DIR,
|
||||
stdout=subprocess.PIPE,
|
||||
check=False,
|
||||
|
@ -509,7 +509,7 @@ class ForceImportErrorOn:
|
|||
if name in self.__module_names:
|
||||
importerror_fromlist = self.__module_names.get(name)
|
||||
if importerror_fromlist is None:
|
||||
raise ImportError("Forced ImportError raised for {!r}".format(name))
|
||||
raise ImportError(f"Forced ImportError raised for {name!r}")
|
||||
|
||||
if importerror_fromlist.intersection(set(fromlist)):
|
||||
raise ImportError(
|
||||
|
@ -699,7 +699,7 @@ def with_system_user(
|
|||
log.debug("Failed to create system user")
|
||||
# The user was not created
|
||||
if on_existing == "skip":
|
||||
cls.skipTest("Failed to create system user {!r}".format(username))
|
||||
cls.skipTest(f"Failed to create system user {username!r}")
|
||||
|
||||
if on_existing == "delete":
|
||||
log.debug("Deleting the system user %r", username)
|
||||
|
@ -727,7 +727,7 @@ def with_system_user(
|
|||
hashed_password = password
|
||||
else:
|
||||
hashed_password = salt.utils.pycrypto.gen_hash(password=password)
|
||||
hashed_password = "'{}'".format(hashed_password)
|
||||
hashed_password = f"'{hashed_password}'"
|
||||
add_pwd = cls.run_function(
|
||||
"shadow.set_password", [username, hashed_password]
|
||||
)
|
||||
|
@ -806,7 +806,7 @@ def with_system_group(group, on_existing="delete", delete=True):
|
|||
log.debug("Failed to create system group")
|
||||
# The group was not created
|
||||
if on_existing == "skip":
|
||||
cls.skipTest("Failed to create system group {!r}".format(group))
|
||||
cls.skipTest(f"Failed to create system group {group!r}")
|
||||
|
||||
if on_existing == "delete":
|
||||
log.debug("Deleting the system group %r", group)
|
||||
|
@ -903,7 +903,7 @@ def with_system_user_and_group(username, group, on_existing="delete", delete=Tru
|
|||
log.debug("Failed to create system user")
|
||||
# The user was not created
|
||||
if on_existing == "skip":
|
||||
cls.skipTest("Failed to create system user {!r}".format(username))
|
||||
cls.skipTest(f"Failed to create system user {username!r}")
|
||||
|
||||
if on_existing == "delete":
|
||||
log.debug("Deleting the system user %r", username)
|
||||
|
@ -930,7 +930,7 @@ def with_system_user_and_group(username, group, on_existing="delete", delete=Tru
|
|||
log.debug("Failed to create system group")
|
||||
# The group was not created
|
||||
if on_existing == "skip":
|
||||
cls.skipTest("Failed to create system group {!r}".format(group))
|
||||
cls.skipTest(f"Failed to create system group {group!r}")
|
||||
|
||||
if on_existing == "delete":
|
||||
log.debug("Deleting the system group %r", group)
|
||||
|
@ -1099,7 +1099,7 @@ def _check_required_sminion_attributes(sminion_attr, *required_items):
|
|||
available_items = list(getattr(sminion, sminion_attr))
|
||||
not_available_items = set()
|
||||
|
||||
name = "__not_available_{items}s__".format(items=sminion_attr)
|
||||
name = f"__not_available_{sminion_attr}s__"
|
||||
if not hasattr(sminion, name):
|
||||
setattr(sminion, name, set())
|
||||
|
||||
|
@ -1181,13 +1181,13 @@ def skip_if_binaries_missing(*binaries, **kwargs):
|
|||
if salt.utils.path.which(binary) is None:
|
||||
return skip(
|
||||
"{}The {!r} binary was not found".format(
|
||||
message and "{}. ".format(message) or "", binary
|
||||
message and f"{message}. " or "", binary
|
||||
)
|
||||
)
|
||||
elif salt.utils.path.which_bin(binaries) is None:
|
||||
return skip(
|
||||
"{}None of the following binaries was found: {}".format(
|
||||
message and "{}. ".format(message) or "", ", ".join(binaries)
|
||||
message and f"{message}. " or "", ", ".join(binaries)
|
||||
)
|
||||
)
|
||||
return _id
|
||||
|
@ -1747,7 +1747,7 @@ class VirtualEnv:
|
|||
pytest.fail("'virtualenv' binary not found")
|
||||
cmd = [
|
||||
virtualenv,
|
||||
"--python={}".format(self.get_real_python()),
|
||||
f"--python={self.get_real_python()}",
|
||||
]
|
||||
if self.system_site_packages:
|
||||
cmd.append("--system-site-packages")
|
||||
|
@ -1880,7 +1880,7 @@ class Keys:
|
|||
|
||||
@property
|
||||
def pub_path(self):
|
||||
return self.priv_path.with_name("{}.pub".format(self.priv_path.name))
|
||||
return self.priv_path.with_name(f"{self.priv_path.name}.pub")
|
||||
|
||||
@property
|
||||
def pub(self):
|
||||
|
|
|
@ -87,7 +87,7 @@ class Collector(salt.utils.process.SignalHandlingProcess):
|
|||
self.sock = self.ctx.socket(zmq.SUB)
|
||||
self.sock.setsockopt(zmq.LINGER, -1)
|
||||
self.sock.setsockopt(zmq.SUBSCRIBE, b"")
|
||||
pub_uri = "tcp://{}:{}".format(self.interface, self.port)
|
||||
pub_uri = f"tcp://{self.interface}:{self.port}"
|
||||
log.info("Collector listen %s", pub_uri)
|
||||
self.sock.connect(pub_uri)
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue