Search in sources :

Example 1 with ParamsGroup

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

the class PydevConsoleRunnerImpl method doCreateConsoleCmdLine.

@NotNull
protected GeneralCommandLine doCreateConsoleCmdLine(Sdk sdk, Map<String, String> environmentVariables, String workingDir, int[] ports, PythonHelper helper) {
    GeneralCommandLine cmd = PythonCommandLineState.createPythonCommandLine(myProject, new PythonConsoleRunParams(myConsoleSettings, workingDir, sdk, environmentVariables), false, PtyCommandLine.isEnabled() && !SystemInfo.isWindows);
    cmd.withWorkDirectory(myWorkingDir);
    ParamsGroup group = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
    helper.addToGroup(group, cmd);
    for (int port : ports) {
        group.addParameter(String.valueOf(port));
    }
    return cmd;
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ParamsGroup

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

the class RestCommandLineState method buildCommandLineParameters.

@Override
protected void buildCommandLineParameters(GeneralCommandLine commandLine) {
    ParametersList parametersList = commandLine.getParametersList();
    ParamsGroup exeOptions = parametersList.getParamsGroup(GROUP_EXE_OPTIONS);
    assert exeOptions != null;
    exeOptions.addParametersString(myConfiguration.getInterpreterOptions());
    ParamsGroup scriptParameters = parametersList.getParamsGroup(GROUP_SCRIPT);
    assert scriptParameters != null;
    getRunner().addToGroup(scriptParameters, commandLine);
    final String key = getKey();
    if (key != null)
        scriptParameters.addParameter(key);
    scriptParameters.addParameter(getTask());
    final String params = myConfiguration.getParams();
    if (params != null)
        scriptParameters.addParametersString(params);
    if (!StringUtil.isEmptyOrSpaces(myConfiguration.getInputFile()))
        scriptParameters.addParameter(myConfiguration.getInputFile());
    if (!StringUtil.isEmptyOrSpaces(myConfiguration.getOutputFile()))
        scriptParameters.addParameter(myConfiguration.getOutputFile());
    if (!StringUtil.isEmptyOrSpaces(myConfiguration.getWorkingDirectory()))
        commandLine.setWorkDirectory(myConfiguration.getWorkingDirectory());
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup) ParametersList(com.intellij.execution.configurations.ParametersList)

Example 3 with ParamsGroup

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

the class SphinxBaseCommand method createCommandLine.

protected GeneralCommandLine createCommandLine(Module module, List<String> params) throws ExecutionException {
    Sdk sdk = PythonSdkType.findPythonSdk(module);
    if (sdk == null) {
        throw new ExecutionException("No sdk specified");
    }
    ReSTService service = ReSTService.getInstance(module);
    String sdkHomePath = sdk.getHomePath();
    GeneralCommandLine cmd = new GeneralCommandLine();
    if (sdkHomePath != null) {
        final String runnerName = "sphinx-quickstart" + (SystemInfo.isWindows ? ".exe" : "");
        String executablePath = PythonSdkType.getExecutablePath(sdkHomePath, runnerName);
        if (executablePath != null) {
            cmd.setExePath(executablePath);
        } else {
            cmd = PythonHelper.LOAD_ENTRY_POINT.newCommandLine(sdkHomePath, Lists.<String>newArrayList());
        }
    }
    cmd.setWorkDirectory(service.getWorkdir().isEmpty() ? module.getProject().getBaseDir().getPath() : service.getWorkdir());
    PythonCommandLineState.createStandardGroups(cmd);
    ParamsGroup scriptParams = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
    assert scriptParams != null;
    if (params != null) {
        for (String p : params) {
            scriptParams.addParameter(p);
        }
    }
    final Map<String, String> env = cmd.getEnvironment();
    setPythonIOEncoding(env, "utf-8");
    setPythonUnbuffered(env);
    if (sdkHomePath != null) {
        resetHomePathChanges(sdkHomePath, env);
    }
    env.put("PYCHARM_EP_DIST", "Sphinx");
    env.put("PYCHARM_EP_NAME", "sphinx-quickstart");
    List<String> pathList = Lists.newArrayList(PythonCommandLineState.getAddedPaths(sdk));
    pathList.addAll(PythonCommandLineState.collectPythonPath(module));
    PythonCommandLineState.initPythonPath(cmd, true, pathList, sdkHomePath);
    PythonSdkType.patchCommandLineForVirtualenv(cmd, sdkHomePath, true);
    BuildoutFacet facet = BuildoutFacet.getInstance(module);
    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) ReSTService(com.jetbrains.python.ReSTService) Sdk(com.intellij.openapi.projectRoots.Sdk) ExecutionException(com.intellij.execution.ExecutionException)

Example 4 with ParamsGroup

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

the class PyCCCommandLineState method buildCommandLineParameters.

@Override
protected void buildCommandLineParameters(GeneralCommandLine commandLine) {
    commandLine.setWorkDirectory(myTaskDir.getPath());
    ParamsGroup group = commandLine.getParametersList().getParamsGroup(GROUP_SCRIPT);
    assert group != null;
    Project project = myRunConfiguration.getProject();
    Course course = StudyTaskManager.getInstance(project).getCourse();
    assert course != null;
    group.addParameter(myRunConfiguration.getPathToTest());
    group.addParameter(new File(course.getCourseDirectory()).getPath());
    String path = getCurrentTaskFilePath();
    if (path != null) {
        group.addParameter(path);
    }
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup) Project(com.intellij.openapi.project.Project) Course(com.jetbrains.edu.learning.courseFormat.Course) VirtualFile(com.intellij.openapi.vfs.VirtualFile) TaskFile(com.jetbrains.edu.learning.courseFormat.TaskFile) File(java.io.File)

Example 5 with ParamsGroup

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

the class BuildoutFacet method patchCommandLineForBuildout.

public void patchCommandLineForBuildout(GeneralCommandLine commandLine) {
    Map<String, String> env = commandLine.getEnvironment();
    ParametersList params = commandLine.getParametersList();
    // alter execution script
    ParamsGroup scriptParams = params.getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
    assert scriptParams != null;
    if (scriptParams.getParameters().size() > 0) {
        // expect DjangoUtil.MANAGE_FILE
        String normalScript = scriptParams.getParameters().get(0);
        HelperPackage engulfer = PythonHelper.BUILDOUT_ENGULFER;
        env.put("PYCHARM_ENGULF_SCRIPT", getConfiguration().getScriptName());
        scriptParams.getParametersList().replaceOrPrepend(normalScript, engulfer.asParamString());
    }
    // add pycharm helpers to pythonpath so that fixGetpass is importable
    PythonEnvUtil.addToPythonPath(env, PythonHelpersLocator.getHelpersRoot().getAbsolutePath());
/*
    // set prependable paths
    List<String> paths = facet.getAdditionalPythonPath();
    if (paths != null) {
      path_value = PyUtil.joinWith(File.pathSeparator, paths);
      env.put("PYCHARM_PREPEND_SYSPATH", path_value);
    }
    */
}
Also used : ParamsGroup(com.intellij.execution.configurations.ParamsGroup) ParametersList(com.intellij.execution.configurations.ParametersList) HelperPackage(com.jetbrains.python.HelperPackage)

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