Search in sources :

Example 6 with ProcessOutput

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

the class PythonSdkFlavor method getVersionString.

@Nullable
public String getVersionString(@Nullable String sdkHome) {
    if (sdkHome == null) {
        return null;
    }
    final String runDirectory = new File(sdkHome).getParent();
    final ProcessOutput processOutput = PySdkUtil.getProcessOutput(runDirectory, new String[] { sdkHome, getVersionOption() }, 10000);
    return getVersionStringFromOutput(processOutput);
}
Also used : ProcessOutput(com.intellij.execution.process.ProcessOutput) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with ProcessOutput

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

the class PySkeletonGenerator method generateBuiltinSkeletons.

public void generateBuiltinSkeletons(@NotNull Sdk sdk) throws InvalidSdkException {
    //noinspection ResultOfMethodCallIgnored
    new File(mySkeletonsPath).mkdirs();
    String binaryPath = sdk.getHomePath();
    if (binaryPath == null)
        throw new InvalidSdkException("Broken home path for " + sdk.getName());
    long startTime = System.currentTimeMillis();
    final ProcessOutput runResult = getProcessOutput(new File(binaryPath).getParent(), new String[] { binaryPath, PythonHelpersLocator.getHelperPath(GENERATOR3), // output dir
    "-d", // output dir
    mySkeletonsPath, // for builtins
    "-b" }, PythonSdkType.getVirtualEnvExtraEnv(binaryPath), MINUTE * 5);
    runResult.checkSuccess(LOG);
    LOG.info("Rebuilding builtin skeletons took " + (System.currentTimeMillis() - startTime) + " ms");
}
Also used : ProcessOutput(com.intellij.execution.process.ProcessOutput) SkeletonVersionChecker.fromVersionString(com.jetbrains.python.sdk.skeletons.SkeletonVersionChecker.fromVersionString) InvalidSdkException(com.jetbrains.python.sdk.InvalidSdkException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 8 with ProcessOutput

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

the class PySkeletonGenerator method generateSkeleton.

protected void generateSkeleton(String modname, String modfilename, List<String> assemblyRefs, String syspath, String sdkHomePath, Consumer<Boolean> resultConsumer) throws InvalidSdkException {
    final ProcessOutput genResult = runSkeletonGeneration(modname, modfilename, assemblyRefs, sdkHomePath, syspath);
    if (genResult.getStderrLines().size() > 0) {
        StringBuilder sb = new StringBuilder("Skeleton for ");
        sb.append(modname);
        if (genResult.getExitCode() != 0) {
            sb.append(" failed on ");
        } else {
            sb.append(" had some minor errors on ");
        }
        sb.append(sdkHomePath).append(". stderr: --\n");
        for (String err_line : genResult.getStderrLines()) {
            sb.append(err_line).append("\n");
        }
        sb.append("--");
        if (ApplicationManagerEx.getApplicationEx().isInternal()) {
            LOG.warn(sb.toString());
        } else {
            LOG.info(sb.toString());
        }
    }
    resultConsumer.consume(genResult.getExitCode() == 0);
}
Also used : ProcessOutput(com.intellij.execution.process.ProcessOutput) SkeletonVersionChecker.fromVersionString(com.jetbrains.python.sdk.skeletons.SkeletonVersionChecker.fromVersionString)

Example 9 with ProcessOutput

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

the class PySkeletonGenerator method listBinaries.

@NotNull
public ListBinariesResult listBinaries(@NotNull Sdk sdk, @NotNull String extraSysPath) throws InvalidSdkException {
    final String homePath = sdk.getHomePath();
    final long startTime = System.currentTimeMillis();
    if (homePath == null)
        throw new InvalidSdkException("Broken home path for " + sdk.getName());
    final String parentDir = new File(homePath).getParent();
    List<String> cmd = new ArrayList<>(Arrays.asList(homePath, PythonHelpersLocator.getHelperPath(GENERATOR3), "-v", "-L"));
    if (!StringUtil.isEmpty(extraSysPath)) {
        cmd.add("-s");
        cmd.add(extraSysPath);
    }
    final ProcessOutput process = getProcessOutput(parentDir, ArrayUtil.toStringArray(cmd), PythonSdkType.getVirtualEnvExtraEnv(homePath), // see PY-3898
    MINUTE * 4);
    LOG.info("Retrieving binary module list took " + (System.currentTimeMillis() - startTime) + " ms");
    if (process.getExitCode() != 0) {
        final StringBuilder sb = new StringBuilder("failed to run ").append(GENERATOR3).append(" for ").append(homePath);
        if (process.isTimeout()) {
            sb.append(": timed out.");
        } else {
            sb.append(", exit code ").append(process.getExitCode()).append(", stderr: \n-----\n");
            for (String line : process.getStderrLines()) {
                sb.append(line).append("\n");
            }
            sb.append("-----");
        }
        throw new InvalidSdkException(sb.toString());
    }
    final List<String> lines = process.getStdoutLines();
    if (lines.size() < 1) {
        throw new InvalidSdkException("Empty output from " + GENERATOR3 + " for " + homePath);
    }
    final Iterator<String> iter = lines.iterator();
    final int generatorVersion = fromVersionString(iter.next().trim());
    final Map<String, PySkeletonRefresher.PyBinaryItem> binaries = Maps.newHashMap();
    while (iter.hasNext()) {
        final String line = iter.next();
        int cutpos = line.indexOf('\t');
        if (cutpos >= 0) {
            String[] strs = line.split("\t");
            String moduleName = strs[0];
            String path = strs[1];
            int length = Integer.parseInt(strs[2]);
            int lastModified = Integer.parseInt(strs[3]);
            binaries.put(moduleName, new PySkeletonRefresher.PyBinaryItem(moduleName, path, length, lastModified));
        } else {
            // but don't die yet
            LOG.error("Bad binaries line: '" + line + "', SDK " + homePath);
        }
    }
    return new ListBinariesResult(generatorVersion, binaries);
}
Also used : SkeletonVersionChecker.fromVersionString(com.jetbrains.python.sdk.skeletons.SkeletonVersionChecker.fromVersionString) ProcessOutput(com.intellij.execution.process.ProcessOutput) InvalidSdkException(com.jetbrains.python.sdk.InvalidSdkException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with ProcessOutput

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

the class SvnRenameTest method testRenameReplace.

// IDEADEV-18844
@Test
public void testRenameReplace() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile a = createFileInCommand("a.txt", "old");
    final VirtualFile aNew = createFileInCommand("aNew.txt", "new");
    checkin();
    renameFileInCommand(a, "aOld.txt");
    renameFileInCommand(aNew, "a.txt");
    final ProcessOutput result = runSvn("status");
    verifySorted(result, "A + aOld.txt", "D aNew.txt", "R + a.txt");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProcessOutput(com.intellij.execution.process.ProcessOutput) Test(org.junit.Test)

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