コード例 #1
0
  /**
   * Patches the command line parameters applying patchers from first to last, and then runs it.
   *
   * @param patchers any number of patchers; any patcher may be null, and the whole argument may be
   *     null.
   * @return handler of the started process
   * @throws ExecutionException
   */
  protected ProcessHandler startProcess(CommandLinePatcher... patchers) throws ExecutionException {
    GeneralCommandLine commandLine = generateCommandLine(patchers);

    // Extend command line
    PythonRunConfigurationExtensionsManager.getInstance()
        .patchCommandLine(
            myConfig, getRunnerSettings(), commandLine, getEnvironment().getRunner().getRunnerId());
    Sdk sdk = PythonSdkType.findSdkByPath(myConfig.getInterpreterPath());
    final ProcessHandler processHandler;
    if (PySdkUtil.isRemote(sdk)) {
      PyRemotePathMapper pathMapper = createRemotePathMapper();
      processHandler =
          createRemoteProcessStarter()
              .startRemoteProcess(sdk, commandLine, myConfig.getProject(), pathMapper);
    } else {
      EncodingEnvironmentUtil.setLocaleEnvironmentIfMac(commandLine);
      processHandler = doCreateProcess(commandLine);
      ProcessTerminatedListener.attach(processHandler);
    }

    // attach extensions
    PythonRunConfigurationExtensionsManager.getInstance()
        .attachExtensionsToProcess(myConfig, processHandler, getRunnerSettings());

    return processHandler;
  }
コード例 #2
0
 private TextConsoleBuilder createConsoleBuilder(Project project) {
   if (isDebug()) {
     return new PyDebugConsoleBuilder(
         project, PythonSdkType.findSdkByPath(myConfig.getInterpreterPath()));
   } else {
     return TextConsoleBuilderFactory.getInstance().createBuilder(project);
   }
 }
コード例 #3
0
 private static void buildPythonPath(
     Project project, GeneralCommandLine commandLine, PythonRunParams config) {
   Sdk pythonSdk = PythonSdkType.findSdkByPath(config.getSdkHome());
   if (pythonSdk != null) {
     List<String> pathList = Lists.newArrayList(getAddedPaths(pythonSdk));
     pathList.addAll(collectPythonPath(project, config));
     initPythonPath(commandLine, config.isPassParentEnvs(), pathList, config.getSdkHome());
   }
 }