use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class SvnRenameTest method testCommitAfterRenameDir.
// IDEADEV-19065
@Test
public void testCommitAfterRenameDir() throws Exception {
final VirtualFile child = prepareDirectoriesForRename();
renameFileInCommand(child, "newchild");
checkin();
final ProcessOutput runResult = runSvn("log", "-q", "newchild/a.txt");
verify(runResult);
final List<String> lines = StringUtil.split(runResult.getStdout(), "\n");
for (Iterator<String> iterator = lines.iterator(); iterator.hasNext(); ) {
final String next = iterator.next();
if (next.startsWith(LOG_SEPARATOR_START)) {
iterator.remove();
}
}
Assert.assertEquals(2, lines.size());
Assert.assertTrue(lines.get(0).startsWith("r2 |"));
Assert.assertTrue(lines.get(1).startsWith("r1 |"));
}
use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class GitVersion method identifyVersion.
@NotNull
public static GitVersion identifyVersion(String gitExecutable) throws TimeoutException, ExecutionException, ParseException {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(gitExecutable);
commandLine.addParameter("--version");
commandLine.setCharset(CharsetToolkit.getDefaultSystemCharset());
CapturingProcessHandler handler = new CapturingProcessHandler(commandLine);
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
ProcessOutput result = indicator == null ? handler.runProcess(ExecutableValidator.TIMEOUT_MS) : handler.runProcessWithProgressIndicator(indicator);
if (result.isTimeout()) {
throw new TimeoutException("Couldn't identify the version of Git - stopped by timeout.");
} else if (result.isCancelled()) {
LOG.info("Cancelled by user. exitCode=" + result.getExitCode());
throw new ProcessCanceledException();
} else if (result.getExitCode() != 0 || !result.getStderr().isEmpty()) {
LOG.info("getVersion exitCode=" + result.getExitCode() + " errors: " + result.getStderr());
// anyway trying to parse
try {
parse(result.getStdout());
} catch (ParseException pe) {
throw new ExecutionException("Errors while executing git --version. exitCode=" + result.getExitCode() + " errors: " + result.getStderr());
}
}
return parse(result.getStdout());
}
use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class PyCondaManagementService method removeRepository.
@Override
public void removeRepository(String repositoryUrl) {
final String conda = PyCondaPackageService.getCondaExecutable(mySdk.getHomeDirectory());
final ArrayList<String> parameters = Lists.newArrayList(conda, "config", "--remove", "channels", repositoryUrl, "--force");
final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);
try {
final CapturingProcessHandler handler = new CapturingProcessHandler(commandLine);
final ProcessOutput result = handler.runProcess();
final int exitCode = result.getExitCode();
if (exitCode != 0) {
final String message = StringUtil.isEmptyOrSpaces(result.getStdout()) && StringUtil.isEmptyOrSpaces(result.getStderr()) ? "Permission denied" : "Non-zero exit code";
LOG.warn("Failed to remove repository " + message);
}
PyCondaPackageService.getInstance().removeChannel(repositoryUrl);
} catch (ExecutionException e) {
LOG.warn("Failed to remove repository");
}
}
use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class PyCondaPackageManagerImpl method createVirtualEnv.
@NotNull
public static String createVirtualEnv(@NotNull String destinationDir, String version) throws ExecutionException {
final String condaExecutable = PyCondaPackageService.getSystemCondaExecutable();
if (condaExecutable == null)
throw new PyExecutionException("Cannot find conda", "Conda", Collections.<String>emptyList(), new ProcessOutput());
final ArrayList<String> parameters = Lists.newArrayList(condaExecutable, "create", "-p", destinationDir, "-y", "python=" + version);
final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);
final CapturingProcessHandler handler = new CapturingProcessHandler(commandLine);
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
final ProcessOutput result = handler.runProcessWithProgressIndicator(indicator);
if (result.isCancelled()) {
throw new RunCanceledByUserException();
}
final int exitCode = result.getExitCode();
if (exitCode != 0) {
final String message = StringUtil.isEmptyOrSpaces(result.getStdout()) && StringUtil.isEmptyOrSpaces(result.getStderr()) ? "Permission denied" : "Non-zero exit code";
throw new PyExecutionException(message, "Conda", parameters, result);
}
final String binary = PythonSdkType.getPythonExecutable(destinationDir);
final String binaryFallback = destinationDir + File.separator + "bin" + File.separator + "python";
return (binary != null) ? binary : binaryFallback;
}
use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class PyCondaPackageManagerImpl method collectPackages.
@NotNull
@Override
protected List<PyPackage> collectPackages() throws ExecutionException {
final ProcessOutput output = getCondaOutput("list", Lists.newArrayList("-e"));
final Set<PyPackage> packages = Sets.newConcurrentHashSet(parseCondaToolOutput(output.getStdout()));
packages.addAll(super.collectPackages());
return Lists.newArrayList(packages);
}
Aggregations