mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 09:40:30 +08:00
improved subprocess cmd logging
This commit is contained in:
parent
0edf854832
commit
43da6af153
@ -175,7 +175,7 @@ class JanusRunner: # pylint: disable=too-many-instance-attributes
|
|||||||
for part in self.__cmd
|
for part in self.__cmd
|
||||||
]
|
]
|
||||||
self.__janus_proc = await aioproc.run_process(cmd)
|
self.__janus_proc = await aioproc.run_process(cmd)
|
||||||
get_logger(0).info("Started Janus pid=%d: %s", self.__janus_proc.pid, cmd)
|
get_logger(0).info("Started Janus pid=%d: %s", self.__janus_proc.pid, tools.cmdfmt(cmd))
|
||||||
|
|
||||||
async def __kill_janus_proc(self) -> None:
|
async def __kill_janus_proc(self) -> None:
|
||||||
if self.__janus_proc:
|
if self.__janus_proc:
|
||||||
|
|||||||
@ -33,6 +33,7 @@ from typing import Optional
|
|||||||
from ....logging import get_logger
|
from ....logging import get_logger
|
||||||
|
|
||||||
from .... import env
|
from .... import env
|
||||||
|
from .... import tools
|
||||||
from .... import aiofs
|
from .... import aiofs
|
||||||
from .... import aioproc
|
from .... import aioproc
|
||||||
|
|
||||||
@ -137,10 +138,10 @@ class HwInfoSubmanager(BaseInfoSubmanager):
|
|||||||
try:
|
try:
|
||||||
text = (await aioproc.read_process(cmd, err_to_null=True))[1]
|
text = (await aioproc.read_process(cmd, err_to_null=True))[1]
|
||||||
except Exception:
|
except Exception:
|
||||||
get_logger(0).exception("Error while executing %s", cmd)
|
get_logger(0).exception("Error while executing: %s", tools.cmdfmt(cmd))
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
return parser(text)
|
return parser(text)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
get_logger(0).error("Can't parse %s output: %r: %s", cmd, text, err)
|
get_logger(0).error("Can't parse [ %s ] output: %r: %s", tools.cmdfmt(cmd), text, tools.efmt(err))
|
||||||
return None
|
return None
|
||||||
|
|||||||
@ -453,7 +453,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
for part in self.__cmd
|
for part in self.__cmd
|
||||||
]
|
]
|
||||||
self.__streamer_proc = await aioproc.run_process(cmd)
|
self.__streamer_proc = await aioproc.run_process(cmd)
|
||||||
get_logger(0).info("Started streamer pid=%d: %s", self.__streamer_proc.pid, cmd)
|
get_logger(0).info("Started streamer pid=%d: %s", self.__streamer_proc.pid, tools.cmdfmt(cmd))
|
||||||
|
|
||||||
async def __kill_streamer_proc(self) -> None:
|
async def __kill_streamer_proc(self) -> None:
|
||||||
if self.__streamer_proc:
|
if self.__streamer_proc:
|
||||||
|
|||||||
@ -131,7 +131,7 @@ class _Service: # pylint: disable=too-many-instance-attributes
|
|||||||
async def __run_ctl(self, ctl: BaseCtl, direct: bool) -> bool:
|
async def __run_ctl(self, ctl: BaseCtl, direct: bool) -> bool:
|
||||||
logger = get_logger()
|
logger = get_logger()
|
||||||
cmd = ctl.get_command(direct)
|
cmd = ctl.get_command(direct)
|
||||||
logger.info("CMD: %s", " ".join(cmd))
|
logger.info("CMD: %s", tools.cmdfmt(cmd))
|
||||||
try:
|
try:
|
||||||
return (not (await aioproc.log_process(cmd, logger)).returncode)
|
return (not (await aioproc.log_process(cmd, logger)).returncode)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|||||||
@ -83,7 +83,8 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
|
|||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
raise RuntimeError(f"Custom command error: retcode={proc.returncode}")
|
raise RuntimeError(f"Custom command error: retcode={proc.returncode}")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
get_logger(0).error("Can't run custom command %s: %s", self.__cmd, tools.efmt(err))
|
get_logger(0).error("Can't run custom command [ %s ]: %s",
|
||||||
|
tools.cmdfmt(self.__cmd), tools.efmt(err))
|
||||||
raise GpioDriverOfflineError(self)
|
raise GpioDriverOfflineError(self)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user