本文整理汇总了Java中com.intellij.execution.process.ProcessOutput.getStdout方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessOutput.getStdout方法的具体用法?Java ProcessOutput.getStdout怎么用?Java ProcessOutput.getStdout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.process.ProcessOutput
的用法示例。
在下文中一共展示了ProcessOutput.getStdout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVersionStringFromOutput
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Nullable
public String getVersionStringFromOutput(@NotNull ProcessOutput processOutput) {
if (processOutput.getExitCode() != 0) {
String errors = processOutput.getStderr();
if (StringUtil.isEmpty(errors)) {
errors = processOutput.getStdout();
}
LOG.warn("Couldn't get interpreter version: process exited with code " + processOutput.getExitCode() + "\n" + errors);
return null;
}
final String result = getVersionStringFromOutput(processOutput.getStderr());
if (result != null) {
return result;
}
return getVersionStringFromOutput(processOutput.getStdout());
}
示例2: loadProjectStructureFromScript
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
private static String loadProjectStructureFromScript(
@NotNull String scriptPath,
@NotNull Consumer<String> statusConsumer,
@Nullable ProcessAdapter processAdapter
) throws IOException, ExecutionException {
final GeneralCommandLine commandLine = PantsUtil.defaultCommandLine(scriptPath);
commandLine.setExePath(scriptPath);
statusConsumer.consume("Executing " + PathUtil.getFileName(scriptPath));
final ProcessOutput processOutput = PantsUtil.getCmdOutput(commandLine, processAdapter);
if (processOutput.checkSuccess(LOG)) {
return processOutput.getStdout();
}
else {
throw new PantsExecutionException("Failed to update the project!", scriptPath, processOutput);
}
}
示例3: getPantsOptions
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public static PantsOptions getPantsOptions(@NotNull final String pantsExecutable) {
File pantsExecutableFile = new File(pantsExecutable);
PantsOptions cache = optionsCache.get(pantsExecutableFile);
if (cache != null) {
return cache;
}
GeneralCommandLine exportCommandline = PantsUtil.defaultCommandLine(pantsExecutable);
exportCommandline.addParameters("options", PantsConstants.PANTS_CLI_OPTION_NO_COLORS);
try {
final ProcessOutput processOutput = PantsUtil.getCmdOutput(exportCommandline, null);
PantsOptions result = new PantsOptions(processOutput.getStdout());
optionsCache.put(pantsExecutableFile, result);
return result;
}
catch (ExecutionException e) {
throw new PantsException("Failed:" + exportCommandline.getCommandLineString());
}
}
示例4: getHelperOutput
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public static String getHelperOutput(String helper) {
final String path = TheRInterpreterService.getInstance().getInterpreterPath();
if (StringUtil.isEmptyOrSpaces(path)) {
LOG.info("Path to interpreter didn't set");
return null;
}
final String helperPath = TheRHelpersLocator.getHelperPath(helper);
try {
final Process process = new GeneralCommandLine(path, "--slave", "-f", helperPath).createProcess();
final CapturingProcessHandler processHandler = new CapturingProcessHandler(process);
final ProcessOutput output = processHandler.runProcess(5 * TheRPsiUtils.MINUTE);
if (output.getExitCode() != 0) {
LOG.error("Failed to run script. Exit code: " + output.getExitCode());
LOG.error(output.getStderrLines());
}
return output.getStdout();
}
catch (ExecutionException e) {
LOG.error(e.getMessage());
}
return null;
}
示例5: uninstallPackage
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public static void uninstallPackage(List<InstalledPackage> repoPackage) throws ExecutionException {
final String path = TheRInterpreterService.getInstance().getInterpreterPath();
if (StringUtil.isEmptyOrSpaces(path)) {
throw new ExecutionException("Please, specify path to the R executable.");
}
final ArrayList<String> arguments = Lists.newArrayList(path, "CMD", "REMOVE");
for (InstalledPackage aRepoPackage : repoPackage) {
arguments.add(aRepoPackage.getName());
}
final Process process = new GeneralCommandLine(arguments).createProcess();
final CapturingProcessHandler processHandler = new CapturingProcessHandler(process);
final ProcessOutput output = processHandler.runProcess(5 * TheRPsiUtils.MINUTE);
if (output.getExitCode() != 0) {
throw new TheRExecutionException("Can't remove package", StringUtil.join(arguments, " "), output.getStdout(),
output.getStderr(), output.getExitCode());
}
}
示例6: getVersionString
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Nullable
@Override
public String getVersionString(String s)
{
try
{
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(getExePath(s).getPath());
commandLine.withWorkDirectory(s);
commandLine.addParameter("-v");
ProcessOutput processOutput = ExecUtil.execAndGetOutput(commandLine);
String stdout = processOutput.getStdout();
if(StringUtil.startsWith(stdout, "v"))
{
stdout = stdout.substring(1, stdout.length());
}
return stdout.trim();
}
catch(ExecutionException e)
{
return null;
}
}
示例7: locateExecutable
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
/**
* Tries to get the absolute path for a command in the PATH.
*/
@Nullable
public static String locateExecutable(@NotNull final String exePath) {
GeneralCommandLine cmdLine = new GeneralCommandLine(
SystemInfo.isWindows ? "where" : "which"
);
cmdLine.addParameter(exePath);
final ProcessOutput processOutput;
try {
processOutput = new CapturingProcessHandler(cmdLine).runProcess();
} catch (ExecutionException e) {
throw new RuntimeException(
"Failed to execute command: " + cmdLine.getCommandLineString(),
e
);
}
final String stdout = processOutput.getStdout();
final String[] lines = stdout.trim().split("\n");
if (lines.length == 0) return null;
return lines[0].trim();
}
示例8: exec
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
private static void exec(GeneralCommandLine command, @Nullable String prompt) throws IOException, ExecutionException {
command.setRedirectErrorStream(true);
ProcessOutput result = prompt != null ? ExecUtil.sudoAndGetOutput(command, prompt) : ExecUtil.execAndGetOutput(command);
int exitCode = result.getExitCode();
if (exitCode != 0) {
String message = "Command '" + (prompt != null ? "sudo " : "") + command.getCommandLineString() + "' returned " + exitCode;
String output = result.getStdout();
if (!StringUtil.isEmptyOrSpaces(output)) message += "\nOutput: " + output.trim();
throw new RuntimeException(message);
}
}
示例9: execAndGetOutput
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
private static String execAndGetOutput(GeneralCommandLine commandLine) throws ExecutionException {
commandLine.setRedirectErrorStream(true);
ProcessOutput output = ExecUtil.execAndGetOutput(commandLine);
String stdout = output.getStdout();
assertEquals("Command:\n" + commandLine.getCommandLineString() + "\nOutput:\n" + stdout, 0, output.getExitCode());
return stdout;
}
示例10: runExternalTool
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Nullable
private static String runExternalTool(@NotNull final Module module,
@NotNull final HelperPackage formatter,
@NotNull final String docstring) {
final Sdk sdk = PythonSdkType.findPython2Sdk(module);
if (sdk == null) return null;
final String sdkHome = sdk.getHomePath();
if (sdkHome == null) return null;
final Charset charset = EncodingProjectManager.getInstance(module.getProject()).getDefaultCharset();
final ByteBuffer encoded = charset.encode(docstring);
final byte[] data = new byte[encoded.limit()];
encoded.get(data);
final Map<String, String> env = new HashMap<String, String>();
PythonEnvUtil.setPythonDontWriteBytecode(env);
final GeneralCommandLine commandLine = formatter.newCommandLine(sdkHome, Lists.<String>newArrayList());
LOG.debug("Command for launching docstring formatter: " + commandLine.getCommandLineString());
final ProcessOutput output = PySdkUtil.getProcessOutput(commandLine, new File(sdkHome).getParent(), env, 5000, data, false);
if (!output.checkSuccess(LOG)) {
return null;
}
return output.getStdout();
}
示例11: generateSkeletonsForList
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
private boolean generateSkeletonsForList(@NotNull final PySkeletonRefresher refresher,
ProgressIndicator indicator,
@Nullable final String currentBinaryFilesPath) throws InvalidSdkException {
final PySkeletonGenerator generator = new PySkeletonGenerator(refresher.getSkeletonsPath(), mySdk, currentBinaryFilesPath);
indicator.setIndeterminate(false);
final String homePath = mySdk.getHomePath();
if (homePath == null) return false;
GeneralCommandLine cmd = PythonHelper.EXTRA_SYSPATH.newCommandLine(homePath, Lists.newArrayList(myQualifiedName));
final ProcessOutput runResult = PySdkUtil.getProcessOutput(cmd,
new File(homePath).getParent(),
PythonSdkType.getVirtualEnvExtraEnv(homePath), 5000
);
if (runResult.getExitCode() == 0 && !runResult.isTimeout()) {
final String extraPath = runResult.getStdout();
final PySkeletonGenerator.ListBinariesResult binaries = generator.listBinaries(mySdk, extraPath);
final List<String> names = Lists.newArrayList(binaries.modules.keySet());
Collections.sort(names);
final int size = names.size();
for (int i = 0; i != size; ++i) {
final String name = names.get(i);
indicator.setFraction((double)i / size);
if (needBinaryList(name)) {
indicator.setText2(name);
final PySkeletonRefresher.PyBinaryItem item = binaries.modules.get(name);
final String modulePath = item != null ? item.getPath() : "";
//noinspection unchecked
refresher.generateSkeleton(name, modulePath, new ArrayList<String>(), Consumer.EMPTY_CONSUMER);
}
}
}
return true;
}
示例12: execute
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
private String execute(@NotNull List<String> parameters, @NotNull File path) throws SvnBindException {
// workaround: separately capture command output - used in exception handling logic to overcome svn 1.8 issue (see below)
final ProcessOutput output = new ProcessOutput();
LineCommandListener listener = new LineCommandAdapter() {
@Override
public void onLineAvailable(String line, Key outputType) {
if (outputType == ProcessOutputTypes.STDOUT) {
output.appendStdout(line);
}
}
};
try {
CommandExecutor command = execute(myVcs, SvnTarget.fromFile(path), SvnCommandName.info, parameters, listener);
return command.getOutput();
}
catch (SvnBindException e) {
final String text = StringUtil.notNullize(e.getMessage());
if (text.contains("W155010")) {
// if "svn info" is executed for several files at once, then this warning could be printed only for some files, but info for other
// files should be parsed from output
return output.getStdout();
}
// not a working copy exception
// "E155007: '' is not a working copy"
if (text.contains("is not a working copy") && StringUtil.isNotEmpty(output.getStdout())) {
// TODO: Seems not reproducible in 1.8.4
// workaround: as in subversion 1.8 "svn info" on a working copy root outputs such error for parent folder,
// if there are files with conflicts.
// but the requested info is still in the output except root closing tag
return output.getStdout() + "</info>";
}
throw e;
}
}
示例13: runCommand
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Nullable
private APIResourceListModel runCommand(String resource, String action, List<String> params) {
APIResourceListModel resourceList = new APIResourceListModel();
GeneralCommandLine gcl = new GeneralCommandLine(clientPath,
resource);
gcl.addParameter(action);
if (params != null) {
gcl.addParameters(params);
}
gcl.addParameter("--access-token");
gcl.addParameter(accessToken);
gcl.withWorkDirectory(workingDir);
try {
final CapturingProcessHandler processHandler = new CapturingProcessHandler(gcl.createProcess(), Charset.defaultCharset(), gcl.getCommandLineString());
ProcessOutput output = processHandler.runProcess();
if (output.getExitCode() != 0) {
String error = output.getStderr();
resourceList.addError(error);
return resourceList;
}
final String response = output.getStdout();
APIResourceListModel resources = null;
if (!response.isEmpty()) {
resources = handleResponse(response);
}
return resources;
} catch (ExecutionException e) {
e.printStackTrace();
}
return resourceList;
}
示例14: getHelpForFunction
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
/**
* If packageName parameter equals null we do not load package
*/
public static String getHelpForFunction(@NotNull final PsiElement assignee, @Nullable final String packageName) {
final String helpHelper = packageName != null ? "r-help.r" : "r-help-without-package.r";
final File file = TheRHelpersLocator.getHelperFile(helpHelper);
final String path = TheRInterpreterService.getInstance().getInterpreterPath();
final String helperPath = file.getAbsolutePath();
try {
final String assigneeText = assignee.getText().replaceAll("\"", "");
final ArrayList<String> arguments = Lists.newArrayList(path, "--slave", "-f ", helperPath, " --args ");
if (packageName != null) {
arguments.add(packageName);
}
arguments.add(assigneeText);
final GeneralCommandLine commandLine = new GeneralCommandLine(arguments);
final Process process = commandLine.createProcess();
final CapturingProcessHandler processHandler = new CapturingProcessHandler(process);
final ProcessOutput output = processHandler.runProcess(MINUTE * 5);
String stdout = output.getStdout();
if (stdout.startsWith("No documentation")) {
return null;
}
return stdout;
}
catch (ExecutionException e) {
LOG.error(e);
}
return null;
}
示例15: visitCallExpression
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Override
public void visitCallExpression(@NotNull TheRCallExpression o) {
if (!myFunctionName.equals(o.getExpression().getName())) {
return;
}
if (myOk != null && !myOk) {
return;
}
String packageQuoted = "\"" + myPackageName + "\"";
String programString = "library(package=" + packageQuoted + ", character.only=TRUE);"
+ "loadNamespace(package=" + packageQuoted + ");"
+ "source(\"" + myExamplesFile + "\");"
+ "myValueType<-class(" + o.getText() + ");"
+ "print(myValueType)";
String rPath = TheRInterpreterService.getInstance().getInterpreterPath();
try {
GeneralCommandLine gcl = new GeneralCommandLine();
gcl.withWorkDirectory(myExamplesFile.getParent().getPath());
gcl.setExePath(rPath);
gcl.addParameter("--slave");
gcl.addParameter("-e");
gcl.addParameter(programString);
Process rProcess = gcl.createProcess();
final CapturingProcessHandler processHandler = new CapturingProcessHandler(rProcess);
final ProcessOutput output = processHandler.runProcess(20000);
String stdout = output.getStdout();
TheRType evaluatedType = TheRSkeletonGeneratorHelper.findType(stdout);
myOk = TheRTypeChecker.matchTypes(myCandidate, evaluatedType);
}
catch (ExecutionException e) {
e.printStackTrace();
}
}