diff --git a/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py b/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py index 518bc542b42e..cfe95a69226b 100644 --- a/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py +++ b/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py @@ -419,6 +419,10 @@ class BaseInterpreterInterface: server = property(get_server) + def show_console(self): + server = self.get_server() + server.ShowConsole() + def finish_exec(self, more): self.interruptable = False diff --git a/python/helpers/pydev/pydev_run_in_console.py b/python/helpers/pydev/pydev_run_in_console.py index 82def8781785..d5a5531a16b1 100644 --- a/python/helpers/pydev/pydev_run_in_console.py +++ b/python/helpers/pydev/pydev_run_in_console.py @@ -79,4 +79,6 @@ if __name__ == '__main__': interpreter.get_namespace().update(globals) + interpreter.show_console() + process_exec_queue(interpreter) \ No newline at end of file diff --git a/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java b/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java index d546ebb449d1..7d95f1e648d3 100644 --- a/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java +++ b/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java @@ -103,6 +103,8 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl private PythonDebugConsoleCommunication myDebugCommunication; private boolean myNeedsMore = false; + private PythonConsoleView myConsoleView; + /** * Initializes the xml-rpc communication. * @@ -185,6 +187,10 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl else if ("NotifyAboutMagic".equals(method)) { return execNotifyAboutMagic(params); } + else if ("ShowConsole".equals(method)) { + myConsoleView.setConsoleEnabled(true); + return ""; + } else { throw new UnsupportedOperationException(); } @@ -676,4 +682,8 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl return true; } } + + public void setConsoleView(PythonConsoleView consoleView) { + myConsoleView = consoleView; + } } diff --git a/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java b/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java index e7204f18932a..b3b961d1cc7d 100644 --- a/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java +++ b/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java @@ -149,6 +149,7 @@ public class PydevConsoleRunnerImpl implements PydevConsoleRunner { private String myCommandLine; @NotNull private final PyConsoleOptions.PyConsoleSettings myConsoleSettings; private String[] myStatementsToExecute = ArrayUtil.EMPTY_STRING_ARRAY; + private boolean myEnableAfterConnection = true; private static final long APPROPRIATE_TO_WAIT = 60000; @@ -180,6 +181,10 @@ public class PydevConsoleRunnerImpl implements PydevConsoleRunner { myConsoleTitle = consoleTitle; } + public void setEnableAfterConnection(boolean enableAfterConnection) { + myEnableAfterConnection = enableAfterConnection; + } + private List fillToolBarActions(final DefaultActionGroup toolbarActions, final RunContentDescriptor contentDescriptor) { //toolbarActions.add(backspaceHandlingAction); @@ -664,7 +669,9 @@ public class PydevConsoleRunnerImpl implements PydevConsoleRunner { } }); - enableConsoleExecuteAction(); + if (myEnableAfterConnection) { + enableConsoleExecuteAction(); + } for (String statement : statements2execute) { consoleView.executeStatement(statement + "\n", ProcessOutputTypes.SYSTEM); diff --git a/python/src/com/jetbrains/python/run/PythonScriptCommandLineState.java b/python/src/com/jetbrains/python/run/PythonScriptCommandLineState.java index b0797faad76c..cacf1fde1e72 100644 --- a/python/src/com/jetbrains/python/run/PythonScriptCommandLineState.java +++ b/python/src/com/jetbrains/python/run/PythonScriptCommandLineState.java @@ -34,7 +34,6 @@ import com.intellij.util.ArrayUtil; import com.jetbrains.python.PythonHelper; import com.jetbrains.python.console.PyConsoleOptions; import com.jetbrains.python.console.PyConsoleType; -import com.jetbrains.python.console.PydevConsoleRunner; import com.jetbrains.python.console.PydevConsoleRunnerImpl; import com.jetbrains.python.console.actions.ShowVarsAction; import com.jetbrains.python.sdk.PythonEnvUtil; @@ -69,16 +68,18 @@ public class PythonScriptCommandLineState extends PythonCommandLineState { })); } - PydevConsoleRunner runner = + PythonScriptWithConsoleRunner runner = new PythonScriptWithConsoleRunner(myConfig.getProject(), myConfig.getSdk(), PyConsoleType.PYTHON, myConfig.getWorkingDirectory(), myConfig.getEnvs(), patchers, PyConsoleOptions.getInstance(myConfig.getProject()).getPythonConsoleSettings()); + runner.setEnableAfterConnection(false); runner.runSync(); // runner.getProcessHandler() would be null if execution error occurred if (runner.getProcessHandler() == null) { return null; } + runner.getPydevConsoleCommunication().setConsoleView(runner.getConsoleView()); List actions = Lists.newArrayList(createActions(runner.getConsoleView(), runner.getProcessHandler())); actions.add(new ShowVarsAction(runner.getConsoleView(), runner.getPydevConsoleCommunication()));