From c8df32e6aea500c2ccb3abe951a81de102b6d78c Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Wed, 20 Mar 2024 20:47:17 -0400 Subject: [PATCH] server: fix windows color depth detection (#1388) --- server/python/plugin_repl.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/python/plugin_repl.py b/server/python/plugin_repl.py index 19205325c..60ee2e18c 100644 --- a/server/python/plugin_repl.py +++ b/server/python/plugin_repl.py @@ -10,6 +10,7 @@ import prompt_toolkit.application.current import prompt_toolkit.key_binding.key_processor import prompt_toolkit.contrib.telnet.server from prompt_toolkit.contrib.telnet.server import TelnetServer, TelnetConnection +from prompt_toolkit.output.color_depth import ColorDepth from prompt_toolkit.shortcuts import clear_title, set_title from ptpython.repl import embed, PythonRepl, _has_coroutine_flag import ptpython.key_bindings @@ -29,6 +30,10 @@ from scrypted_python.scrypted_sdk import ScryptedStatic, ScryptedDevice from rpc import maybe_await +# Our client is xtermjs, so no need to perform any color depth detection +ColorDepth.default = lambda *args, **kwargs: ColorDepth.DEPTH_4_BIT + + # This section is a bit of a hack - prompt_toolkit has many assumptions # that there is only one global Application, so multiple REPLs will confuse # the library. The patches here allow us to scope a particular call stack @@ -267,6 +272,7 @@ async def createREPLServer(sdk: ScryptedStatic, plugin: ScryptedDevice) -> int: # we're not in the main loop, so can't handle any signals anyways repl_loop.add_signal_handler = lambda sig, cb: None + repl_loop.remove_signal_handler = lambda sig: True def finish_setup(): telnet_port, exit_server = server_started_future.result()