From 46edd8a49a57fee62e07ee4d0c98a0d6e804c68a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 15 Mar 2024 17:11:12 -0400 Subject: [PATCH] Add a stub backdoor replacement --- confluent_server/confluent/debugger.py | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 confluent_server/confluent/debugger.py diff --git a/confluent_server/confluent/debugger.py b/confluent_server/confluent/debugger.py new file mode 100644 index 00000000..41fc152d --- /dev/null +++ b/confluent_server/confluent/debugger.py @@ -0,0 +1,31 @@ +import code +import sys + +#this will ultimately fill the role of the 'backdoor' of eventlet + +# since we have to asyncio up the input and output, we use InteractiveInterpreter and handle the +# input ourselves, since code is not asyncio friendly in and of itself +#code.InteractiveConsole().interact() +prompt = '>>> ' +itr = code.InteractiveInterpreter() +while True: + sys.stdout.write(prompt) + prompt = '... ' + sys.stdout.flush() + newinput = input() + somecode += newinput + '\n' + if newinput.startswith(' '): + prompt = '... ' + continue + try: + compcode = code.compile_command(somecode) + except SyntaxError as e: + print(repr(e)) + compcode = None + somecode = '' + prompt = '>>> ' + if compcode: + itr.runcode(compcode) + somecode = '' + prompt = '>>> ' +