mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PyCharm does not wait till script is finished and start console (PY-21496)
Console shouldn't be enabled by default, we should send a separate notification in order to enable it.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -79,4 +79,6 @@ if __name__ == '__main__':
|
||||
|
||||
interpreter.get_namespace().update(globals)
|
||||
|
||||
interpreter.show_console()
|
||||
|
||||
process_exec_queue(interpreter)
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<AnAction> 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);
|
||||
|
||||
@@ -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<AnAction> actions = Lists.newArrayList(createActions(runner.getConsoleView(), runner.getProcessHandler()));
|
||||
actions.add(new ShowVarsAction(runner.getConsoleView(), runner.getPydevConsoleCommunication()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user