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);
}
use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class CreateLauncherScriptAction method createLauncherScript.
public static void createLauncherScript(@NotNull String pathName) throws Exception {
if (!isAvailable())
return;
File scriptFile = createLauncherScriptFile();
try {
File scriptTarget = new File(pathName);
File scriptTargetDir = scriptTarget.getParentFile();
assert scriptTargetDir != null : "path: " + pathName;
if (!(scriptTargetDir.exists() || scriptTargetDir.mkdirs()) || !scriptFile.renameTo(scriptTarget)) {
String scriptTargetDirPath = scriptTargetDir.getCanonicalPath();
// copy file and change ownership to root (UID 0 = root, GID 0 = root (wheel on Macs))
String installationScriptSrc = "#!/bin/sh\n" + "mkdir -p \"" + scriptTargetDirPath + "\"\n" + "install -g 0 -o 0 \"" + scriptFile.getCanonicalPath() + "\" \"" + pathName + "\"";
File installationScript = ExecUtil.createTempExecutableScript("launcher_installer", ".sh", installationScriptSrc);
String prompt = ApplicationBundle.message("launcher.script.sudo.prompt", scriptTargetDirPath);
ProcessOutput result = ExecUtil.sudoAndGetOutput(new GeneralCommandLine(installationScript.getPath()), prompt);
int exitCode = result.getExitCode();
if (exitCode != 0) {
String message = "Launcher script creation failed with " + exitCode;
String output = result.getStdout();
if (!StringUtil.isEmptyOrSpaces(output))
message += "\nOutput: " + output.trim();
throw new RuntimeException(message);
}
}
} finally {
if (scriptFile.exists()) {
FileUtil.delete(scriptFile);
}
}
}
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 SvnExecutableChecker method validateLocale.
@Nullable
private Notification validateLocale() throws SvnBindException {
ProcessOutput versionOutput = getVersionClient().runCommand(false);
Notification result = null;
Matcher matcher = INVALID_LOCALE_WARNING_PATTERN.matcher(versionOutput.getStderr());
if (matcher.find()) {
LOG.info(matcher.group());
result = new ExecutableNotValidNotification(prepareDescription(UIUtil.getHtmlBody(matcher.group()), false), NotificationType.WARNING);
} else if (!isEnglishOutput(versionOutput.getStdout())) {
LOG.info("\"svn --version\" command contains non-English output " + versionOutput.getStdout());
result = new ExecutableNotValidNotification(prepareDescription(SvnBundle.message("non.english.locale.detected.warning"), false), NotificationType.WARNING);
}
return result;
}
use of com.intellij.execution.process.ProcessOutput in project intellij-community by JetBrains.
the class HgTestRepository method create.
/**
* Creates a new Mercurial repository in a new temporary test directory.
* @param test reference to the test case instance.
* @return created repository.
*/
public static HgTestRepository create(HgTest test) throws Exception {
final TempDirTestFixture dirFixture = createFixtureDir();
final File repo = new File(dirFixture.getTempDirPath());
final ProcessOutput processOutput = test.runHg(repo, "init");
AbstractVcsTestCase.verify(processOutput);
return new HgTestRepository(test, dirFixture);
}
Aggregations