Skip to content

Commit

Permalink
vistel console fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hpcdgrie committed Oct 7, 2024
1 parent 765211c commit 056b7ba
Showing 1 changed file with 21 additions and 39 deletions.
60 changes: 21 additions & 39 deletions app/gui/vistleconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,51 +281,33 @@ void VistleConsole::init()
#endif

try {
#ifdef USE_RLCOMPLETER
PyRun_SimpleString("import sys\n"

"import _redirector\n"
"sys.stdout = _redirector.redirector()\n"
"sys.stderr = _redirector.redirector(True)\n"

"sys.path.insert(0, \".\")\n" // add current path

"import _console\n"

"import builtins\n"
"builtins.clear=_console.clear\n"
"builtins.reset=_console.reset\n"
"builtins.save=_console.save\n"
"builtins.load=_console.load\n"
"builtins.history=_console.history\n"
//"builtins.quit=_console.quit\n"
//"builtins.exit=_console.quit\n"
"builtins.input=_console.raw_input\n"
"import rlcompleter\n"
"builtins.completer=rlcompleter.Completer()\n");
#else
PyRun_SimpleString("import sys\n"
std::string pyCode = "import sys\n"

"import _redirector\n"
"sys.stdout = _redirector.redirector()\n"
"sys.stderr = _redirector.redirector(True)\n"
"import _redirector\n"
"sys.stdout = _redirector.redirector()\n"
"sys.stderr = _redirector.redirector(True)\n"

"sys.path.insert(0, \".\")\n" // add current path
"sys.path.insert(0, \".\")\n" // add current path

"import _console\n"
"import _console\n"

"import builtins\n"
"builtins.clear=_console.clear\n"
"builtins.reset=_console.reset\n"
"builtins.save=_console.save\n"
"builtins.load=_console.load\n"
"builtins.history=_console.history\n"
//"builtins.quit=_console.quit\n"
//"builtins.exit=_console.quit\n"
"builtins.input=_console.raw_input\n"
"import builtins\n"
"builtins.clear=_console.clear\n"
"builtins.reset=_console.reset\n"
"builtins.save=_console.save\n"
"builtins.load=_console.load\n"
"builtins.history=_console.history\n"
//"builtins.quit=_console.quit\n"
//"builtins.exit=_console.quit\n"
"builtins.input=_console.raw_input\n"

);
#ifdef USE_RLCOMPLETER
"import rlcompleter\n"
"builtins.completer=rlcompleter.Completer()\n"
#endif
;
PyRun_SimpleString(pyCode.c_str());

} catch (...) {
std::cerr << "error running Python initialisation" << std::endl;
}
Expand Down

0 comments on commit 056b7ba

Please sign in to comment.