Search in sources :

Example 11 with ProcessOutput

use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.

the class SvnRenameTest method testRenamePackageWithChildren.

// IDEADEV-15876
@Test
public void testRenamePackageWithChildren() throws Exception {
    final VirtualFile child = prepareDirectoriesForRename();
    renameFileInCommand(child, "childnew");
    final ProcessOutput result = runSvn("status");
    verifySorted(result, "A + childnew", "D child", "D child" + File.separatorChar + "a.txt", "D child" + File.separatorChar + "grandChild", "D child" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt");
    // wait for end of refresh operations initiated from SvnFileSystemListener
    refreshVfs();
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    insideInitializedChangeListManager(changeListManager, () -> {
        changeListManager.ensureUpToDate(false);
        List<Change> changes = new ArrayList<>(changeListManager.getDefaultChangeList().getChanges());
        Assert.assertEquals(4, changes.size());
        sortChanges(changes);
        verifyChange(changes.get(0), "child", "childnew");
        verifyChange(changes.get(1), "child" + File.separatorChar + "a.txt", "childnew" + File.separatorChar + "a.txt");
        verifyChange(changes.get(2), "child" + File.separatorChar + "grandChild", "childnew" + File.separatorChar + "grandChild");
        verifyChange(changes.get(3), "child" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt", "childnew" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt");
    });
// there is no such directory any more
/*VirtualFile oldChild = myWorkingCopyDir.findChild("child");
    if (oldChild == null) {
      myWorkingCopyDir.refresh(false, true);
      oldChild = myWorkingCopyDir.findChild("child");
    }
    Assert.assertEquals(FileStatus.DELETED, changeListManager.getStatus(oldChild));*/
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProcessOutput(com.intellij.execution.process.ProcessOutput) ArrayList(java.util.ArrayList) Change(com.intellij.openapi.vcs.changes.Change) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 12 with ProcessOutput

use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.

the class GenerateBinaryStubsFix method generateSkeletonsForList.

private boolean generateSkeletonsForList(@NotNull final PySkeletonRefresher refresher, ProgressIndicator indicator, @Nullable final String currentBinaryFilesPath) throws InvalidSdkException {
    final PySkeletonGenerator generator = new PySkeletonGenerator(refresher.getSkeletonsPath(), mySdk, currentBinaryFilesPath);
    indicator.setIndeterminate(false);
    final String homePath = mySdk.getHomePath();
    if (homePath == null)
        return false;
    GeneralCommandLine cmd = PythonHelper.EXTRA_SYSPATH.newCommandLine(homePath, Lists.newArrayList(myQualifiedName));
    final ProcessOutput runResult = PySdkUtil.getProcessOutput(cmd, new File(homePath).getParent(), PythonSdkType.getVirtualEnvExtraEnv(homePath), 5000);
    if (runResult.getExitCode() == 0 && !runResult.isTimeout()) {
        final String extraPath = runResult.getStdout();
        final PySkeletonGenerator.ListBinariesResult binaries = generator.listBinaries(mySdk, extraPath);
        final List<String> names = Lists.newArrayList(binaries.modules.keySet());
        Collections.sort(names);
        final int size = names.size();
        for (int i = 0; i != size; ++i) {
            final String name = names.get(i);
            indicator.setFraction((double) i / size);
            if (needBinaryList(name)) {
                indicator.setText2(name);
                final PySkeletonRefresher.PyBinaryItem item = binaries.modules.get(name);
                final String modulePath = item != null ? item.getPath() : "";
                //noinspection unchecked
                refresher.generateSkeleton(name, modulePath, new ArrayList<>(), Consumer.EMPTY_CONSUMER);
            }
        }
    }
    return true;
}
Also used : PySkeletonRefresher(com.jetbrains.python.sdk.skeletons.PySkeletonRefresher) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ProcessOutput(com.intellij.execution.process.ProcessOutput) PySkeletonGenerator(com.jetbrains.python.sdk.skeletons.PySkeletonGenerator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File)

Example 13 with ProcessOutput

use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.

the class Pep8ExternalAnnotator method doAnnotate.

@Nullable
@Override
public Results doAnnotate(State collectedInfo) {
    if (collectedInfo == null)
        return null;
    ArrayList<String> options = Lists.newArrayList();
    if (!collectedInfo.ignoredErrors.isEmpty()) {
        options.add("--ignore=" + DEFAULT_IGNORED_ERRORS + "," + StringUtil.join(collectedInfo.ignoredErrors, ","));
    }
    if (collectedInfo.hangClosingBrackets) {
        options.add("--hang-closing");
    }
    options.add("--max-line-length=" + collectedInfo.margin);
    options.add("-");
    GeneralCommandLine cmd = PythonHelper.PYCODESTYLE.newCommandLine(collectedInfo.interpreterPath, options);
    ProcessOutput output = PySdkUtil.getProcessOutput(cmd, new File(collectedInfo.interpreterPath).getParent(), ImmutableMap.of("PYTHONBUFFERED", "1"), 10000, collectedInfo.fileText.getBytes(), false);
    Results results = new Results(collectedInfo.level);
    if (output.isTimeout()) {
        LOG.info("Timeout running pycodestyle.py");
    } else if (output.getStderrLines().isEmpty()) {
        for (String line : output.getStdoutLines()) {
            final Problem problem = parseProblem(line);
            if (problem != null) {
                results.problems.add(problem);
            }
        }
    } else if (((ApplicationInfoImpl) ApplicationInfo.getInstance()).isEAP()) {
        LOG.info("Error running pycodestyle.py: " + output.getStderr());
    }
    return results;
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ProcessOutput(com.intellij.execution.process.ProcessOutput) ApplicationInfoImpl(com.intellij.openapi.application.impl.ApplicationInfoImpl) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 14 with ProcessOutput

use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.

the class HgTestRepository method cloneRepository.

/**
   * Clones a repository from this one. New repository is located in a new temporary test directory.
   * @return New repository cloned from this one.
   */
public HgTestRepository cloneRepository() throws Exception {
    final TempDirTestFixture dirFixture = createFixtureDir();
    final ProcessOutput processOutput = myTest.runHg(null, "clone", getDirFixture().getTempDirPath(), dirFixture.getTempDirPath());
    AbstractVcsTestCase.verify(processOutput);
    return new HgTestRepository(myTest, dirFixture);
}
Also used : TempDirTestFixture(com.intellij.testFramework.fixtures.TempDirTestFixture) ProcessOutput(com.intellij.execution.process.ProcessOutput)

Example 15 with ProcessOutput

use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.

the class HgUpdateTest method determineNumberOfIncomingChanges.

private int determineNumberOfIncomingChanges(File repo) throws IOException {
    ProcessOutput result = runHg(repo, "-q", "incoming", "--template", "{rev} ");
    String output = result.getStdout();
    return output.length() == 0 ? 0 : output.split(" ").length;
}
Also used : ProcessOutput(com.intellij.execution.process.ProcessOutput)

Aggregations

ProcessOutput (com.intellij.execution.process.ProcessOutput)57 File (java.io.File)22 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)20 VirtualFile (com.intellij.openapi.vfs.VirtualFile)19 ExecutionException (com.intellij.execution.ExecutionException)18 CapturingProcessHandler (com.intellij.execution.process.CapturingProcessHandler)13 Nullable (org.jetbrains.annotations.Nullable)10 NotNull (org.jetbrains.annotations.NotNull)9 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 CapturingAnsiEscapesAwareProcessHandler (com.intellij.execution.process.CapturingAnsiEscapesAwareProcessHandler)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Sdk (com.intellij.openapi.projectRoots.Sdk)3 PsiFile (com.intellij.psi.PsiFile)3 SkeletonVersionChecker.fromVersionString (com.jetbrains.python.sdk.skeletons.SkeletonVersionChecker.fromVersionString)3 IOException (java.io.IOException)3 PhoneGapCommandLine (com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapCommandLine)2 Change (com.intellij.openapi.vcs.changes.Change)2 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)2 TempDirTestFixture (com.intellij.testFramework.fixtures.TempDirTestFixture)2