From fd48e10ff40a4ebac33d18410e00cf5a24f1b521 Mon Sep 17 00:00:00 2001 From: haskal Date: Wed, 12 May 2021 16:57:49 -0400 Subject: [PATCH] more refactor --- megacom/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/megacom/__init__.py b/megacom/__init__.py index 0d1c647..8cc3926 100644 --- a/megacom/__init__.py +++ b/megacom/__init__.py @@ -111,7 +111,12 @@ async def megacom(tty: str, baud: int, mode: str) -> None: loop = asyncio.get_event_loop() keycodes = KeycodeHandler() + return await megacom_main(stdin, stdout, tty, baud, bytesize, parity, stopbits, loop, keycodes) + +async def megacom_main(stdin: asyncio.StreamReader, stdout: asyncio.StreamWriter, tty: str, + baud: int, bytesize: Any, parity: Any, stopbits: Any, + loop: asyncio.AbstractEventLoop, keycodes: KeycodeHandler) -> None: printed_fnf = False while True: @@ -153,7 +158,7 @@ async def megacom(tty: str, baud: int, mode: str) -> None: await stdout.drain() return - stdout.write(f"megacom connected to {tty}:{baud}:{mode}\r\n".encode()) + stdout.write(f"megacom connected to {tty}\r\n".encode()) await stdout.drain() async def connect_pipe(pin: asyncio.StreamReader, pout: asyncio.StreamWriter, @@ -216,7 +221,8 @@ async def megacom(tty: str, baud: int, mode: str) -> None: await stdout.drain() if do_retry: - return await megacom(tty, baud, mode) + return await megacom_main(stdin, stdout, tty, baud, bytesize, parity, stopbits, loop, + keycodes) def main() -> None: