コード例 #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
  public GeneralCommandLine generateCommandLine() {
    GeneralCommandLine commandLine = createPythonCommandLine(myConfig.getProject(), myConfig);

    buildCommandLineParameters(commandLine);

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

    return commandLine;
  }
コード例 #3
0
 @Nullable
 private PyRemotePathMapper createRemotePathMapper() {
   if (myConfig.getMappingSettings() == null) {
     return null;
   } else {
     return PyRemotePathMapper.fromSettings(
         myConfig.getMappingSettings(), PyRemotePathMapper.PyPathMappingType.USER_DEFINED);
   }
 }
コード例 #4
0
 protected void addTracebackFilter(
     Project project, ConsoleView consoleView, ProcessHandler processHandler) {
   if (PySdkUtil.isRemote(myConfig.getSdk())) {
     assert processHandler instanceof RemoteProcessControl;
     consoleView.addMessageFilter(
         new PyRemoteTracebackFilter(
             project, myConfig.getWorkingDirectory(), (RemoteProcessControl) processHandler));
   } else {
     consoleView.addMessageFilter(
         new PythonTracebackFilter(project, myConfig.getWorkingDirectorySafe()));
   }
   consoleView.addMessageFilter(
       createUrlFilter(processHandler)); // Url filter is always nice to have
 }
コード例 #5
0
 public boolean isMultiprocessDebug() {
   if (myMultiprocessDebug != null) {
     return myMultiprocessDebug;
   } else {
     return PyDebuggerOptionsProvider.getInstance(myConfig.getProject()).isAttachToSubprocess();
   }
 }
コード例 #6
0
 protected String getInterpreterPath() throws ExecutionException {
   String interpreterPath = myConfig.getInterpreterPath();
   if (interpreterPath == null) {
     throw new ExecutionException("Cannot find Python interpreter for this run configuration");
   }
   return interpreterPath;
 }
コード例 #7
0
 private TextConsoleBuilder createConsoleBuilder(Project project) {
   if (isDebug()) {
     return new PyDebugConsoleBuilder(
         project, PythonSdkType.findSdkByPath(myConfig.getInterpreterPath()));
   } else {
     return TextConsoleBuilderFactory.getInstance().createBuilder(project);
   }
 }
コード例 #8
0
  public ExecutionResult execute(Executor executor, CommandLinePatcher... patchers)
      throws ExecutionException {
    final ProcessHandler processHandler = startProcess(patchers);
    final ConsoleView console =
        createAndAttachConsole(myConfig.getProject(), processHandler, executor);

    List<AnAction> actions = Lists.newArrayList(createActions(console, processHandler));

    return new DefaultExecutionResult(
        console, processHandler, actions.toArray(new AnAction[actions.size()]));
  }
コード例 #9
0
 public Sdk getSdk() {
   return myConfig.getSdk();
 }
コード例 #10
0
 @Nullable
 public PythonSdkFlavor getSdkFlavor() {
   return PythonSdkFlavor.getFlavor(myConfig.getInterpreterPath());
 }