use of com.intellij.execution.process.ProcessOutput in project intellij-plugins by JetBrains.
the class PhoneGapPluginsView method checkParams.
private PhoneGapCommandLine checkParams(Ref<String> error, Ref<String> warning, Ref<String> version, String path, String workDir) throws ExecutionException {
boolean pathError = false;
if (!new File(workDir).exists()) {
pathError = true;
workDir = myProject.getBasePath();
}
PhoneGapCommandLine commandLine = new PhoneGapCommandLine(path, workDir);
if (!commandLine.isCorrectExecutable()) {
error.set(PhoneGapBundle.message("phonegap.plugins.executable.error"));
return commandLine;
}
version.set(commandLine.version());
if (pathError) {
error.set(PhoneGapBundle.message("phonegap.plugins.executable.work.path.error", commandLine.getPlatformName()));
return commandLine;
}
ProcessOutput output = commandLine.pluginListRaw();
if (!StringUtil.isEmpty(output.getStderr())) {
error.set(PhoneGapBundle.message("phonegap.plugins.executable.work.path.error", commandLine.getPlatformName()));
return commandLine;
}
if (commandLine.isOld()) {
warning.set(PhoneGapBundle.message("phonegap.plugins.executable.version.error"));
}
return commandLine;
}
use of com.intellij.execution.process.ProcessOutput in project intellij-plugins by JetBrains.
the class PhoneGapTargets method list.
protected List<String> list(String executableName, Function<String, String> parser, boolean errorOut, String... params) {
List<String> result = ContainerUtil.newArrayList();
File deployExecutable = PathEnvironmentVariableUtil.findInPath(executableName);
if (deployExecutable == null)
return result;
try {
GeneralCommandLine line = new GeneralCommandLine(deployExecutable.getAbsolutePath());
line.addParameters(params);
ProcessOutput output = ExecUtil.execAndGetOutput(line);
List<String> lines = null;
if (errorOut) {
if (!StringUtil.isEmpty(output.getStderr())) {
lines = output.getStderrLines();
}
}
if (lines == null) {
lines = output.getStdoutLines();
}
if (output.getExitCode() != 0)
return result;
for (String value : lines) {
ContainerUtil.addIfNotNull(result, parser.fun(value));
}
} catch (ExecutionException e) {
LOGGER.debug(e.getMessage(), e);
}
return result;
}
use of com.intellij.execution.process.ProcessOutput in project intellij-elixir by KronicDeth.
the class MixConfigurationForm method validateMixPath.
private boolean validateMixPath() {
String mixPath = myMixPathSelector.getText();
File mix = new File(mixPath);
if (!mix.exists()) {
return false;
}
if (!mix.canExecute()) {
String reason = mix.getPath() + "is not executable.";
LOGGER.warn("Can't detect Mix version: " + reason);
return false;
}
File exeFile = mix.getAbsoluteFile();
String exePath = exeFile.getPath();
String workDir = exeFile.getParent();
ProcessOutput output = null;
boolean valid = false;
for (String[] arguments : MIX_ARGUMENTS_ARRAY) {
try {
output = ElixirSystemUtil.getProcessOutput(3000, workDir, exePath, arguments);
} catch (ExecutionException executionException) {
LOGGER.warn(executionException);
}
if (output != null) {
String transformedStdout = transformStdoutLine(output, STDOUT_LINE_TRANSFORMER);
if (transformedStdout != null) {
myMixVersionText.setText(transformedStdout);
String versionString = transformedStdout.replaceAll("^[^0-9]*", "");
// Support for the --formatter option may be added in a 1.3.x release, but I'm being conservative for now
// and assuming it won't be released until 1.4
ElixirSdkRelease elixirSdkRelease = ElixirSdkRelease.fromString(versionString);
if (elixirSdkRelease != null) {
supportsFormatterOptionCheckBox.setSelected(elixirSdkRelease.compareTo(ElixirSdkRelease.V_1_4) >= 0);
}
valid = true;
break;
} else {
String stderr = output.getStderr();
StringBuilder text = new StringBuilder("N/A");
if (StringUtil.isNotEmpty(stderr)) {
text.append(": Error: ").append(stderr);
}
myMixVersionText.setText(text.toString());
}
}
}
return valid;
}
use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class GeneralCommandLineTest method execAndGetOutput.
private static String execAndGetOutput(GeneralCommandLine commandLine) throws ExecutionException {
ProcessOutput output = ExecUtil.execAndGetOutput(commandLine);
int ec = output.getExitCode();
if (ec != 0) {
fail("Command:\n" + commandLine.getCommandLineString() + "\nStdOut:\n" + output.getStdout() + "\nStdErr:\n" + output.getStderr());
}
return output.getStdout();
}
use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class ProcessListUtil method parseCommandOutput.
@Nullable
private static List<ProcessInfo> parseCommandOutput(@NotNull List<String> command, @NotNull NullableFunction<String, List<ProcessInfo>> parser) {
String output;
try {
ProcessOutput processOutput = ExecUtil.execAndGetOutput(new GeneralCommandLine(command));
int exitCode = processOutput.getExitCode();
if (exitCode != 0) {
LOG.error("Cannot get process list, command '" + StringUtil.join(command, " ") + "' exited with code " + exitCode + ", stdout:\n" + processOutput.getStdout() + "\nstderr:\n" + processOutput.getStderr());
}
output = processOutput.getStdout();
} catch (ExecutionException e) {
LOG.error("Cannot get process list", e);
return null;
}
return parser.fun(output);
}
Aggregations