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)
| 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 | |
| 65 | def _valid_target(t): |
| 66 | return bool(t and isinstance(t, str) and t[0] != '-' and _TARGET_RE.match(t)) |
| 67 | |
| 68 | |
| 69 | def _valid_iface(i): |
| 70 | return bool(i and isinstance(i, str) and i[0] != '-' and _IFACE_RE.match(i)) |
| 71 | |
| 72 | |
| 73 | def _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 | |
| 81 | def _run(cmd, timeout=30, env=None): |
no test coverage detected