Exemplo n.º 1
0
  @NotNull
  public GeneralCommandLine createCommand(
      @NotNull Module module,
      @Nullable String jvmParams,
      boolean forCreation,
      @NotNull MvcCommand command)
      throws ExecutionException {
    final JavaParameters params =
        createJavaParameters(module, forCreation, false, true, jvmParams, command);
    addJavaHome(params, module);

    final GeneralCommandLine commandLine = createCommandLine(params);

    final VirtualFile griffonHome = getSdkRoot(module);
    if (griffonHome != null) {
      commandLine
          .getEnvironment()
          .put(getSdkHomePropertyName(), FileUtil.toSystemDependentName(griffonHome.getPath()));
    }

    final VirtualFile root = findAppRoot(module);
    final File ioRoot =
        root != null ? VfsUtilCore.virtualToIoFile(root) : new File(module.getModuleDirPath());
    commandLine.setWorkDirectory(forCreation ? ioRoot.getParentFile() : ioRoot);

    return commandLine;
  }
  public GeneralCommandLine generateCommandLine() {
    GeneralCommandLine commandLine = createPythonCommandLine(myConfig.getProject(), myConfig);

    buildCommandLineParameters(commandLine);

    customizeEnvironmentVars(commandLine.getEnvironment(), myConfig.isPassParentEnvs());

    return commandLine;
  }
  @NotNull
  public static GeneralCommandLine createPythonCommandLine(
      Project project, PythonRunParams config) {
    GeneralCommandLine commandLine = generalCommandLine();

    createStandardGroups(commandLine);

    initEnvironment(project, commandLine, config);

    commandLine.withCharset(EncodingProjectManager.getInstance(project).getDefaultCharset());

    setRunnerPath(project, commandLine, config);

    return commandLine;
  }
 protected static void setRunnerPath(
     Project project, GeneralCommandLine commandLine, PythonRunParams config) {
   String interpreterPath = getInterpreterPath(project, config);
   if (StringUtil.isNotEmpty(interpreterPath)) {
     commandLine.setExePath(FileUtil.toSystemDependentName(interpreterPath));
   }
 }
 /**
  * Creates a number of parameter groups in the command line: GROUP_EXE_OPTIONS, GROUP_DEBUGGER,
  * GROUP_SCRIPT. These are necessary for command line patchers to work properly.
  *
  * @param commandLine
  */
 public static void createStandardGroups(GeneralCommandLine commandLine) {
   ParametersList params = commandLine.getParametersList();
   params.addParamsGroup(GROUP_EXE_OPTIONS);
   params.addParamsGroup(GROUP_DEBUGGER);
   params.addParamsGroup(GROUP_PROFILER);
   params.addParamsGroup(GROUP_COVERAGE);
   params.addParamsGroup(GROUP_SCRIPT);
 }
  protected static void initEnvironment(
      Project project, GeneralCommandLine commandLine, PythonRunParams myConfig) {
    Map<String, String> env = myConfig.getEnvs();
    if (env == null) {
      env = new HashMap<String, String>();
    } else {
      env = new HashMap<String, String>(env);
    }

    setupEncodingEnvs(env, commandLine.getCharset());

    addCommonEnvironmentVariables(env);

    commandLine.getEnvironment().clear();
    commandLine.getEnvironment().putAll(env);
    commandLine.withParentEnvironmentType(
        myConfig.isPassParentEnvs() ? ParentEnvironmentType.CONSOLE : ParentEnvironmentType.NONE);

    buildPythonPath(project, commandLine, myConfig);
  }
 public static void initPythonPath(
     GeneralCommandLine commandLine,
     boolean passParentEnvs,
     List<String> pathList,
     final String interpreterPath) {
   final PythonSdkFlavor flavor = PythonSdkFlavor.getFlavor(interpreterPath);
   if (flavor != null) {
     flavor.initPythonPath(commandLine, pathList);
   } else {
     PythonSdkFlavor.initPythonPath(commandLine.getEnvironment(), passParentEnvs, pathList);
   }
 }