From 4974db3117fed1b4b94729533979346c55ccc323 Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 29 Sep 2022 05:08:02 +0800 Subject: [PATCH] fixed debug console --- README.md | 6 +++--- prompt.py | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5c66ddc..6f07aa7 100644 --- a/README.md +++ b/README.md @@ -69,9 +69,9 @@ There're multiple options to run AQuery on Windows. You can use the native toolc In this case, upgrade anaconda or your compiler or use the python from your OS or package manager instead. Or (**NOT recommended**) copy/link the library from your system (e.g. /usr/lib/x86_64-linux-gnu/libstdc++.so.6) to anaconda's library directory (e.g. ~/Anaconda3/lib/). ### Docker: - - Alternatively, you can also use docker to run AQuery. - - Type `make docker` to build the docker image from scratch. - - For Arm-based Mac users, you would have to build and run the x86_64 docker image because MonetDB doesn't offer official binaries for arm64 Linux. (Run `docker buildx build --platform=linux/amd64 -t aquery .` instead of `make docker`) + - See installation instructions from [docker.com](https://www.docker.com). Run docker desktop to start docker engine. + - In AQuery root directory, type `make docker` to build the docker image from scratch. + - For Arm-based Mac users, you would have to build and run the **x86_64** docker image because MonetDB doesn't offer official binaries for arm64 Linux. (Run `docker buildx build --platform=linux/amd64 -t aquery .` instead of `make docker`) - Finally run the image in **interactive** mode (`docker run -it --rm aquery`) ## Usage `python3 prompt.py` will launch the interactive command prompt. The server binary will be automatically rebuilt and started. diff --git a/prompt.py b/prompt.py index 4ad02f0..4bd01e8 100644 --- a/prompt.py +++ b/prompt.py @@ -397,11 +397,15 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None): from copy import deepcopy var = {**globals(), **locals()} sh = code.InteractiveConsole(var) + __stdin = os.dup(0) try: sh.interact(banner = 'debugging session began.', exitmsg = 'debugging session ended.') - except BaseException as e: - # don't care about anything happened in interactive console + except BaseException as e: + # dont care about whatever happened in dbg session print(e) + finally: + import io + sys.stdin = io.TextIOWrapper(io.BufferedReader(io.FileIO(__stdin, mode='rb', closefd=False)), encoding='utf8') continue elif q.startswith('log'): qs = re.split(r'[ \t]', q)