Search in sources :

Example 16 with ParamsGroup

use of com.intellij.execution.configurations.ParamsGroup in project intellij-community by JetBrains.

the class JythonSdkFlavor method initPythonPath.

@Override
public void initPythonPath(GeneralCommandLine cmd, Collection<String> path) {
    initPythonPath(path, cmd.getEnvironment());
    ParamsGroup paramGroup = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_EXE_OPTIONS);
    assert paramGroup != null;
    for (String param : paramGroup.getParameters()) {
        if (param.startsWith(PYTHON_PATH_PREFIX)) {
            return;
        }
    }
    paramGroup.addParameter(getPythonPathCmdLineArgument(path));
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup)

Example 17 with ParamsGroup

use of com.intellij.execution.configurations.ParamsGroup in project intellij-community by JetBrains.

the class PythonScriptCommandLineState method buildCommandLineParameters.

@Override
protected void buildCommandLineParameters(GeneralCommandLine commandLine) {
    ParametersList parametersList = commandLine.getParametersList();
    ParamsGroup exe_options = parametersList.getParamsGroup(GROUP_EXE_OPTIONS);
    assert exe_options != null;
    exe_options.addParametersString(myConfig.getInterpreterOptions());
    ParamsGroup script_parameters = parametersList.getParamsGroup(GROUP_SCRIPT);
    assert script_parameters != null;
    if (!StringUtil.isEmptyOrSpaces(myConfig.getScriptName())) {
        script_parameters.addParameter(myConfig.getScriptName());
    }
    final String script_options_string = myConfig.getScriptParameters();
    if (script_options_string != null)
        script_parameters.addParametersString(script_options_string);
    if (!StringUtil.isEmptyOrSpaces(myConfig.getWorkingDirectory())) {
        commandLine.setWorkDirectory(myConfig.getWorkingDirectory());
    }
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup) ParametersList(com.intellij.execution.configurations.ParametersList)

Example 18 with ParamsGroup

use of com.intellij.execution.configurations.ParamsGroup in project intellij-community by JetBrains.

the class PythonTask method createCommandLine.

public GeneralCommandLine createCommandLine() {
    GeneralCommandLine cmd = new GeneralCommandLine();
    if (myWorkingDirectory != null) {
        cmd.setWorkDirectory(myWorkingDirectory);
    }
    String homePath = mySdk.getHomePath();
    if (homePath != null) {
        homePath = FileUtil.toSystemDependentName(homePath);
    }
    PythonCommandLineState.createStandardGroups(cmd);
    ParamsGroup scriptParams = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
    assert scriptParams != null;
    Map<String, String> env = cmd.getEnvironment();
    if (!SystemInfo.isWindows && !PySdkUtil.isRemote(mySdk)) {
        cmd.setExePath("bash");
        ParamsGroup bashParams = cmd.getParametersList().addParamsGroupAt(0, "Bash");
        bashParams.addParameter("-cl");
        NotNullFunction<String, String> escaperFunction = StringUtil.escaper(false, "|>$\"'& ");
        StringBuilder paramString;
        if (myHelper != null) {
            paramString = new StringBuilder(escaperFunction.fun(homePath) + " " + escaperFunction.fun(myHelper.asParamString()));
            myHelper.addToPythonPath(cmd.getEnvironment());
        } else {
            paramString = new StringBuilder(escaperFunction.fun(homePath) + " " + escaperFunction.fun(myRunnerScript));
        }
        for (String p : myParameters) {
            paramString.append(" ").append(p);
        }
        bashParams.addParameter(paramString.toString());
    } else {
        cmd.setExePath(homePath);
        if (myHelper != null) {
            myHelper.addToGroup(scriptParams, cmd);
        } else {
            scriptParams.addParameter(myRunnerScript);
        }
        scriptParams.addParameters(myParameters.stream().filter(o -> o != null).collect(Collectors.toList()));
    }
    PythonEnvUtil.setPythonUnbuffered(env);
    if (homePath != null) {
        PythonEnvUtil.resetHomePathChanges(homePath, env);
    }
    List<String> pythonPath = setupPythonPath();
    PythonCommandLineState.initPythonPath(cmd, true, pythonPath, homePath);
    BuildoutFacet facet = BuildoutFacet.getInstance(myModule);
    if (facet != null) {
        facet.patchCommandLineForBuildout(cmd);
    }
    return cmd;
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup) BuildoutFacet(com.jetbrains.python.buildout.BuildoutFacet) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine)

Aggregations

ParamsGroup (com.intellij.execution.configurations.ParamsGroup)18 ParametersList (com.intellij.execution.configurations.ParametersList)9 Test (org.junit.Test)6 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)4 BuildoutFacet (com.jetbrains.python.buildout.BuildoutFacet)2 ExecutionException (com.intellij.execution.ExecutionException)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Course (com.jetbrains.edu.learning.courseFormat.Course)1 TaskFile (com.jetbrains.edu.learning.courseFormat.TaskFile)1 HelperPackage (com.jetbrains.python.HelperPackage)1 ReSTService (com.jetbrains.python.ReSTService)1 File (java.io.File)1 NotNull (org.jetbrains.annotations.NotNull)1