MCPcopy
hub / github.com/saltstack/salt / _run

Function _run

tests/pytests/integration/minion/test_process_queue.py:59–87  ·  view source on GitHub ↗
(fun, args=None, kw=None, timeout=60, background=False)

Source from the content-addressed store, hash-verified

57@pytest.fixture
58def run_salt_cmd(salt_cli, configured_minion):
59 def _run(fun, args=None, kw=None, timeout=60, background=False):
60 if args is None:
61 args = []
62 if kw is None:
63 kw = {}
64
65 # Convert kw to string arguments "key=value"
66 kw_args = [f"{k}={v}" for k, v in kw.items()]
67
68 cmd = (
69 [
70 sys.executable,
71 salt_cli.script_name,
72 "-c",
73 str(salt_cli.config_dir),
74 configured_minion.id,
75 fun,
76 ]
77 + list(args)
78 + kw_args
79 )
80
81 # Add client timeout if provided (but not as kwarg to function)
82 cmd.extend(["-t", str(timeout)])
83
84 if background:
85 return subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
86 else:
87 return subprocess.run(cmd, capture_output=True, text=True, check=False)
88
89 return _run
90

Callers

nothing calls this directly

Calls 4

listFunction · 0.50
itemsMethod · 0.45
extendMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected