コード例 #1
0
 @Override
 protected Process createProcess() throws ExecutionException {
   if (PySdkUtil.isRemote(mySdk)) {
     PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance();
     if (manager != null) {
       return createRemoteConsoleProcess(
           manager,
           myCommandLineArgumentsProvider.getArguments(),
           myCommandLineArgumentsProvider.getAdditionalEnvs());
     }
     throw new PythonRemoteInterpreterManager.PyRemoteInterpreterExecutionException();
   } else {
     myCommandLine = myCommandLineArgumentsProvider.getCommandLineString();
     Map<String, String> envs = myCommandLineArgumentsProvider.getAdditionalEnvs();
     if (envs != null) {
       EncodingEnvironmentUtil.fixDefaultEncodingIfMac(envs, getProject());
     }
     final Process server =
         ProcessRunner.createProcess(
             getWorkingDir(), envs, myCommandLineArgumentsProvider.getArguments());
     try {
       myPydevConsoleCommunication =
           new PydevConsoleCommunication(getProject(), myPorts[0], server, myPorts[1]);
     } catch (Exception e) {
       throw new ExecutionException(e.getMessage());
     }
     return server;
   }
 }
コード例 #2
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;
  }