diff options
author | Devaev Maxim <[email protected]> | 2018-12-17 23:25:30 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-12-17 23:25:30 +0300 |
commit | 876c89609f39c87f29dcf3c6659bff52597ce9dd (patch) | |
tree | 1efc8c7013113424ccf70c78b0011352f08c6544 | |
parent | eeecf78796553ac714139847f78c494cfac69d30 (diff) |
removed wscli
-rw-r--r-- | kvmd/apps/wscli/__init__.py | 47 | ||||
-rw-r--r-- | kvmd/apps/wscli/__main__.py | 2 | ||||
-rwxr-xr-x | setup.py | 2 |
3 files changed, 0 insertions, 51 deletions
diff --git a/kvmd/apps/wscli/__init__.py b/kvmd/apps/wscli/__init__.py deleted file mode 100644 index 33d31abf..00000000 --- a/kvmd/apps/wscli/__init__.py +++ /dev/null @@ -1,47 +0,0 @@ -import sys -import signal -import asyncio -import argparse -import time - -import aiohttp - - -# ===== -async def _run_client(loop: asyncio.AbstractEventLoop, url: str) -> None: - def stdin_callback() -> None: - line = sys.stdin.buffer.readline().decode() - if line: - asyncio.ensure_future(ws.send_str(line), loop=loop) - else: - loop.stop() - - loop.add_reader(sys.stdin.fileno(), stdin_callback) - - async def dispatch() -> None: - while True: - msg = await ws.receive() - if msg.type == aiohttp.WSMsgType.TEXT: - print("[%.5f] Received: %s" % (time.time(), msg.data.strip())) - else: - if msg.type == aiohttp.WSMsgType.CLOSE: - await ws.close() - elif msg.type == aiohttp.WSMsgType.ERROR: - print("[%.5f] Error during receive: %s" % (time.time(), ws.exception())) - elif msg.type == aiohttp.WSMsgType.CLOSED: - pass - break - - async with aiohttp.ClientSession().ws_connect(url) as ws: - await dispatch() - - -def main() -> None: - parser = argparse.ArgumentParser() - parser.add_argument("-u", "--url", default="http://127.0.0.1:8081/ws") - options = parser.parse_args() - - loop = asyncio.get_event_loop() - loop.add_signal_handler(signal.SIGINT, loop.stop) - loop.create_task(_run_client(loop, options.url)) - loop.run_forever() diff --git a/kvmd/apps/wscli/__main__.py b/kvmd/apps/wscli/__main__.py deleted file mode 100644 index 031df43e..00000000 --- a/kvmd/apps/wscli/__main__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import main -main() @@ -21,7 +21,6 @@ def main() -> None: "kvmd.apps", "kvmd.apps.kvmd", "kvmd.apps.cleanup", - "kvmd.apps.wscli", ], package_data={ @@ -32,7 +31,6 @@ def main() -> None: "console_scripts": [ "kvmd = kvmd.apps.kvmd:main", "kvmd-cleanup = kvmd.apps.cleanup:main", - "kvmd-wscli = kvmd.apps.wscli:main", ], }, |