Fix debugging for Flask server run configuration (PY-27926)

This commit is contained in:
Elizaveta Shashkova
2018-03-01 18:24:11 +03:00
parent c2f76b8be0
commit 955c6ed94e
4 changed files with 32 additions and 5 deletions
@@ -102,6 +102,7 @@ public abstract class PythonCommandLineState extends CommandLineState {
*/
public static final String GROUP_MODULE = "Module";
public static final String GROUP_SCRIPT = "Script";
public static final String MODULE_PARAMETER = "-m";
private final AbstractPythonRunConfiguration myConfig;
private Boolean myMultiprocessDebug = null;
@@ -269,9 +270,26 @@ public abstract class PythonCommandLineState extends CommandLineState {
return new PyRemoteProcessStarter();
}
/**
* Generate command line and apply patchers
*
* @param patchers array of patchers
* @return generated command line changed by patchers
*/
@NotNull
public final GeneralCommandLine generateCommandLine(@Nullable CommandLinePatcher[] patchers) {
return applyPatchers(generateCommandLine(), patchers);
}
public GeneralCommandLine generateCommandLine(CommandLinePatcher[] patchers) {
GeneralCommandLine commandLine = generateCommandLine();
/**
* Apply patchers to the given command line
*
* @param commandLine command line to change
* @param patchers array of patchers
* @return command line changed by patchers
*/
@NotNull
private static GeneralCommandLine applyPatchers(@NotNull GeneralCommandLine commandLine, @Nullable CommandLinePatcher[] patchers) {
if (patchers != null) {
for (CommandLinePatcher patcher : patchers) {
if (patcher != null) patcher.patchCommandLine(commandLine);
@@ -284,6 +302,14 @@ public abstract class PythonCommandLineState extends CommandLineState {
return PythonProcessRunner.createProcess(commandLine);
}
/**
* Generate command line from run configuration.
* It can be overridden if commandline shouldn't be based on the run configuration or when it requires some additional changes
* before patchers applying.
*
* @return generated command line
*/
@NotNull
public GeneralCommandLine generateCommandLine() {
GeneralCommandLine commandLine = createPythonCommandLine(myConfig.getProject(), myConfig, isDebug(), myRunWithPty);
@@ -230,7 +230,7 @@ public class PythonScriptCommandLineState extends PythonCommandLineState {
ParamsGroup moduleParameters = parametersList.getParamsGroup(GROUP_MODULE);
assert moduleParameters != null;
moduleParameters.addParameter("-m");
moduleParameters.addParameter(MODULE_PARAMETER);
moduleParameters.addParameters(myConfig.getScriptName());
}
else {
@@ -234,8 +234,8 @@ abstract class PyTestExecutionEnvironment<T : PyAbstractTestConfiguration>(confi
override fun getTestSpecs(): MutableList<String> = java.util.ArrayList(configuration.getTestSpec())
override fun generateCommandLine(patchers: Array<out CommandLinePatcher>?): GeneralCommandLine {
val line = super.generateCommandLine(patchers)
override fun generateCommandLine(): GeneralCommandLine {
val line = super.generateCommandLine()
line.workDirectory = java.io.File(configuration.workingDirectorySafe)
return line
}
@@ -97,6 +97,7 @@ public abstract class PythonTestCommandLineStateBase<T extends AbstractPythonRun
return null; // by default, the IDE will use a "file://" protocol locator
}
@NotNull
@Override
public GeneralCommandLine generateCommandLine() {
GeneralCommandLine cmd = super.generateCommandLine();