use of com.intellij.execution.process.ProcessOutput in project android by JetBrains.
the class AvdManagerConnection method checkAcceleration.
/**
* Run "emulator -accel-check" to check the status for emulator acceleration on this machine.
* Return a {@link AccelerationErrorCode}.
*/
public AccelerationErrorCode checkAcceleration() {
if (!initIfNecessary()) {
return AccelerationErrorCode.UNKNOWN_ERROR;
}
File emulatorBinary = getEmulatorBinary();
if (!emulatorBinary.isFile()) {
return AccelerationErrorCode.NO_EMULATOR_INSTALLED;
}
if (getMemorySize() < Storage.Unit.GiB.getNumberOfBytes()) {
// TODO: The emulator -accel-check current does not check for the available memory, do it here instead:
return AccelerationErrorCode.NOT_ENOUGH_MEMORY;
}
if (!hasQEMU2Installed()) {
return AccelerationErrorCode.TOOLS_UPDATE_REQUIRED;
}
File checkBinary = getEmulatorCheckBinary();
GeneralCommandLine commandLine = new GeneralCommandLine();
if (checkBinary.isFile()) {
commandLine.setExePath(checkBinary.getPath());
commandLine.addParameter("accel");
} else {
commandLine.setExePath(emulatorBinary.getPath());
commandLine.addParameter("-accel-check");
}
int exitValue;
try {
CapturingAnsiEscapesAwareProcessHandler process = new CapturingAnsiEscapesAwareProcessHandler(commandLine);
ProcessOutput output = process.runProcess();
exitValue = output.getExitCode();
} catch (ExecutionException e) {
exitValue = AccelerationErrorCode.UNKNOWN_ERROR.getErrorCode();
}
if (exitValue != 0) {
return AccelerationErrorCode.fromExitCode(exitValue);
}
if (!hasPlatformToolsForQEMU2Installed()) {
return AccelerationErrorCode.PLATFORM_TOOLS_UPDATE_ADVISED;
}
if (!hasSystemImagesForQEMU2Installed()) {
return AccelerationErrorCode.SYSTEM_IMAGE_UPDATE_ADVISED;
}
return AccelerationErrorCode.ALREADY_INSTALLED;
}
use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class GitExecutableDetector method runs.
/**
* Checks if it is possible to run the specified program.
* Made protected for tests not to start a process there.
*/
protected boolean runs(@NotNull String exec) {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(exec);
commandLine.setCharset(CharsetToolkit.getDefaultSystemCharset());
try {
CapturingProcessHandler handler = new CapturingProcessHandler(commandLine);
ProcessOutput result = handler.runProcess((int) TimeUnit.SECONDS.toMillis(5));
return !result.isTimeout();
} catch (ExecutionException e) {
return false;
}
}
use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class JdkPopupAction method retrieveJDKLocations.
private static ArrayList<Pair<File, String>> retrieveJDKLocations() {
ArrayList<Pair<File, String>> jdkLocations = new ArrayList<>();
Collection<String> homePaths = JavaSdk.getInstance().suggestHomePaths();
for (final String path : homePaths) {
try {
File file = new File(path);
File javaExe = new File(new File(file, "bin"), "java.exe");
ProcessOutput output = ExecUtil.execAndGetOutput(new GeneralCommandLine(javaExe.getAbsolutePath(), "-version"));
List<String> lines = output.getStderrLines();
if (lines.isEmpty()) {
lines = output.getStdoutLines();
}
StringBuilder stringBuilder = new StringBuilder();
if (lines.size() == 3) {
stringBuilder.append("JDK ");
String line = lines.get(1);
int pos = line.indexOf("(build ");
if (pos != -1) {
stringBuilder.append(line.substring(pos + 7, line.length() - 1));
}
line = lines.get(2);
pos = line.indexOf(" (build");
if (pos != -1) {
String substring = line.substring(0, pos);
stringBuilder.append(" (").append(substring).append(")");
}
} else {
stringBuilder.append(file.getName());
}
jdkLocations.add(Pair.create(file, stringBuilder.toString()));
} catch (ExecutionException e) {
LOG.debug(e);
}
}
return jdkLocations;
}
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;
}
Aggregations