diff options
author | Maxim Devaev <[email protected]> | 2022-06-19 20:42:52 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-06-19 20:47:17 +0300 |
commit | 0edf854832a85c68d09125a0ef1491a093c78d99 (patch) | |
tree | fa43983005c801c4a2a323418d2c46accb4b4eab /kvmd | |
parent | 4aa7a21b5597af3171ff5b7217fe4e6bb3ab5db9 (diff) |
cmdfmt
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/aiohelpers.py | 2 | ||||
-rw-r--r-- | kvmd/tools.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/kvmd/aiohelpers.py b/kvmd/aiohelpers.py index 6357764c..ae943d23 100644 --- a/kvmd/aiohelpers.py +++ b/kvmd/aiohelpers.py @@ -38,7 +38,7 @@ async def remount(name: str, base_cmd: List[str], rw: bool) -> bool: part.format(mode=mode) for part in base_cmd ] - logger.info("Remounting %s storage to %s: %s ...", name, mode.upper(), cmd) + logger.info("Remounting %s storage to %s: %s ...", name, mode.upper(), tools.cmdfmt(cmd)) try: proc = await aioproc.log_process(cmd, logger) if proc.returncode != 0: diff --git a/kvmd/tools.py b/kvmd/tools.py index 7af6723c..77a81d64 100644 --- a/kvmd/tools.py +++ b/kvmd/tools.py @@ -24,6 +24,7 @@ import operator import functools import multiprocessing.queues import queue +import shlex from typing import Tuple from typing import List @@ -38,6 +39,10 @@ def remap(value: int, in_min: int, in_max: int, out_min: int, out_max: int) -> i # ===== +def cmdfmt(cmd: List[str]) -> str: + return " ".join(map(shlex.quote, cmd)) + + def efmt(err: Exception) -> str: return f"{type(err).__name__}: {err}" |