MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _run

Function _run

network_diagnostics.py:63–78  ·  view source on GitHub ↗

Run a command (list of args) and return {rc, out, err}. Never raises: missing binary -> rc 127, timeout -> rc 124.

(cmd, timeout=30, env=None)

Source from the content-addressed store, hash-verified

61_TARGET_RE = re.compile(r'^[A-Za-z0-9._:\-/]{1,255}$')
62_IFACE_RE = re.compile(r'^[A-Za-z0-9._@\-]{1,32}$')
63
64
65def _valid_target(t):
66 return bool(t and isinstance(t, str) and t[0] != '-' and _TARGET_RE.match(t))
67
68
69def _valid_iface(i):
70 return bool(i and isinstance(i, str) and i[0] != '-' and _IFACE_RE.match(i))
71
72
73def _clamp_int(val, default, lo, hi):
74 try:
75 n = int(val)
76 except (TypeError, ValueError):
77 return default
78 return max(lo, min(hi, n))
79
80
81def _run(cmd, timeout=30, env=None):

Callers 15

do_pingFunction · 0.85
do_tracerouteFunction · 0.85
do_mtrFunction · 0.85
do_whoisFunction · 0.85
do_speedtestFunction · 0.85
do_lldpFunction · 0.85
do_arp_scanFunction · 0.85
_list_iface_namesFunction · 0.85
_iface_link_detailsFunction · 0.85
_iface_addrsFunction · 0.85
_iface_ethtoolFunction · 0.85
_iface_ip_methodFunction · 0.85

Calls 1

runMethod · 0.45

Tested by

no test coverage detected