mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 15:33:56 +00:00
tests: update munet 0.14.14, 0.14.15
- improvement to remote CLI - 0.14.15 fixed a small bug in 0.14.14 Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
45e42c15df
commit
68f25a1b74
@ -745,7 +745,7 @@ async def cli_client_connected(unet, background, reader, writer):
|
|||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
|
||||||
|
|
||||||
async def remote_cli(unet, prompt, title, background):
|
async def remote_cli(unet, prompt, title, background, remote_wait=False):
|
||||||
"""Open a CLI in a new window."""
|
"""Open a CLI in a new window."""
|
||||||
try:
|
try:
|
||||||
if not unet.cli_sockpath:
|
if not unet.cli_sockpath:
|
||||||
@ -756,7 +756,12 @@ async def remote_cli(unet, prompt, title, background):
|
|||||||
unet.cli_sockpath = sockpath
|
unet.cli_sockpath = sockpath
|
||||||
logging.info("server created on :\n%s\n", sockpath)
|
logging.info("server created on :\n%s\n", sockpath)
|
||||||
|
|
||||||
wait_tmux = bool(os.getenv("TMUX", "")) and not sys.stdin.isatty()
|
if remote_wait:
|
||||||
|
wait_tmux = bool(os.getenv("TMUX", ""))
|
||||||
|
wait_x11 = not wait_tmux and bool(os.getenv("DISPLAY", ""))
|
||||||
|
else:
|
||||||
|
wait_tmux = False
|
||||||
|
wait_x11 = False
|
||||||
|
|
||||||
# Open a new window with a new CLI
|
# Open a new window with a new CLI
|
||||||
python_path = await unet.async_get_exec_path(["python3", "python"])
|
python_path = await unet.async_get_exec_path(["python3", "python"])
|
||||||
@ -778,14 +783,21 @@ async def remote_cli(unet, prompt, title, background):
|
|||||||
if channel is not None:
|
if channel is not None:
|
||||||
Commander.tmux_wait_gen += 1
|
Commander.tmux_wait_gen += 1
|
||||||
|
|
||||||
unet.run_in_window(cmd, title=title, background=False, wait_for=channel)
|
pane_info = unet.run_in_window(
|
||||||
|
cmd, title=title, background=False, wait_for=channel
|
||||||
|
)
|
||||||
|
|
||||||
if wait_tmux and channel:
|
if wait_tmux and channel:
|
||||||
from .base import commander # pylint: disable=import-outside-toplevel
|
from .base import commander # pylint: disable=import-outside-toplevel
|
||||||
|
|
||||||
|
logger.debug("Waiting on TMUX CLI window")
|
||||||
await commander.async_cmd_raises(
|
await commander.async_cmd_raises(
|
||||||
[commander.get_exec_path("tmux"), "wait", channel]
|
[commander.get_exec_path("tmux"), "wait", channel]
|
||||||
)
|
)
|
||||||
|
elif wait_x11 and isinstance(pane_info, subprocess.Popen):
|
||||||
|
logger.debug("Waiting on xterm CLI process %s", pane_info)
|
||||||
|
if hasattr(asyncio, "to_thread"):
|
||||||
|
await asyncio.to_thread(pane_info.wait) # pylint: disable=no-member
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
logging.error("cli server: unexpected exception: %s", error)
|
logging.error("cli server: unexpected exception: %s", error)
|
||||||
|
|
||||||
@ -926,8 +938,22 @@ def cli(
|
|||||||
prompt=None,
|
prompt=None,
|
||||||
background=True,
|
background=True,
|
||||||
):
|
):
|
||||||
|
# In the case of no tty a remote_cli will be used, and we want it to wait on finish
|
||||||
|
# of the spawned cli.py script, otherwise it returns back here and exits async loop
|
||||||
|
# which kills the server side CLI socket operation.
|
||||||
|
remote_wait = not sys.stdin.isatty()
|
||||||
|
|
||||||
asyncio.run(
|
asyncio.run(
|
||||||
async_cli(unet, histfile, sockpath, force_window, title, prompt, background)
|
async_cli(
|
||||||
|
unet,
|
||||||
|
histfile,
|
||||||
|
sockpath,
|
||||||
|
force_window,
|
||||||
|
title,
|
||||||
|
prompt,
|
||||||
|
background,
|
||||||
|
remote_wait=remote_wait,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -939,12 +965,14 @@ async def async_cli(
|
|||||||
title=None,
|
title=None,
|
||||||
prompt=None,
|
prompt=None,
|
||||||
background=True,
|
background=True,
|
||||||
|
remote_wait=False,
|
||||||
):
|
):
|
||||||
if prompt is None:
|
if prompt is None:
|
||||||
prompt = "munet> "
|
prompt = "munet> "
|
||||||
|
|
||||||
if force_window or not sys.stdin.isatty():
|
if force_window or not sys.stdin.isatty():
|
||||||
await remote_cli(unet, prompt, title, background)
|
await remote_cli(unet, prompt, title, background, remote_wait)
|
||||||
|
return
|
||||||
|
|
||||||
if not unet:
|
if not unet:
|
||||||
logger.debug("client-cli using sockpath %s", sockpath)
|
logger.debug("client-cli using sockpath %s", sockpath)
|
||||||
|
Loading…
Reference in New Issue
Block a user