コード例 #1
0
  public static Map<String, String> addDefaultEnvironments(Sdk sdk, Map<String, String> envs) {
    Charset defaultCharset = EncodingManager.getInstance().getDefaultCharset();

    final String encoding = defaultCharset != null ? defaultCharset.name() : "utf-8";
    setPythonIOEncoding(setPythonUnbuffered(envs), encoding);

    PythonSdkFlavor.initPythonPath(envs, true, PythonCommandLineState.getAddedPaths(sdk));
    return envs;
  }
コード例 #2
0
  protected GeneralCommandLine createCommandLine(Module module, List<String> params)
      throws ExecutionException {
    GeneralCommandLine cmd = new GeneralCommandLine();

    Sdk sdk = PythonSdkType.findPythonSdk(module);
    if (sdk == null) {
      throw new ExecutionException("No sdk specified");
    }

    ReSTService service = ReSTService.getInstance(module);
    cmd.setWorkDirectory(
        service.getWorkdir().isEmpty()
            ? module.getProject().getBaseDir().getPath()
            : service.getWorkdir());
    PythonCommandLineState.createStandardGroupsIn(cmd);
    ParamsGroup script_params =
        cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
    assert script_params != null;

    String commandPath = getCommandPath(sdk);
    if (commandPath == null) {
      throw new ExecutionException("Cannot find sphinx-quickstart.");
    }
    cmd.setExePath(commandPath);

    if (params != null) {
      for (String p : params) {
        script_params.addParameter(p);
      }
    }

    cmd.setPassParentEnvironment(true);
    setPythonIOEncoding(cmd.getEnvironment(), "utf-8");
    setPythonUnbuffered(cmd.getEnvironment());

    List<String> pathList = Lists.newArrayList(PythonCommandLineState.getAddedPaths(sdk));
    pathList.addAll(PythonCommandLineState.collectPythonPath(module));

    PythonCommandLineState.initPythonPath(cmd, true, pathList, sdk.getHomePath());

    PythonSdkType.patchCommandLineForVirtualenv(cmd, sdk.getHomePath(), true);
    BuildoutFacet facet = BuildoutFacet.getInstance(module);
    if (facet != null) {
      facet.patchCommandLineForBuildout(cmd);
    }

    return cmd;
  }