本文整理汇总了Java中com.intellij.execution.process.ProcessOutput.getExitCode方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessOutput.getExitCode方法的具体用法?Java ProcessOutput.getExitCode怎么用?Java ProcessOutput.getExitCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.process.ProcessOutput
的用法示例。
在下文中一共展示了ProcessOutput.getExitCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExecutableVersionOutput
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
private String[] getExecutableVersionOutput(String sdkHome) {
final String exePath = getTopLevelExecutable(sdkHome).getAbsolutePath();
final ProcessOutput processOutput;
try {
processOutput = LuaSystemUtil.getProcessOutput(sdkHome, exePath, "-v");
} catch (final ExecutionException e) {
return null;
}
if (processOutput.getExitCode() != 0) {
return null;
}
//Backwards compatibility - probably for Windows and OSX
final String stderr = processOutput.getStderr().trim();
if (!stderr.isEmpty()) {
return stderr.split(" ");
}
//linux
final String stdout = processOutput.getStdout().trim();
if (!stdout.isEmpty()) {
return stdout.split(" ");
}
return null;
}
示例2: doCheckExecutable
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
protected static boolean doCheckExecutable(@NotNull String executable, @NotNull List<String> processParameters) {
try {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(executable);
commandLine.addParameters(processParameters);
CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
ProcessOutput result = handler.runProcess(TIMEOUT_MS);
boolean timeout = result.isTimeout();
int exitCode = result.getExitCode();
String stderr = result.getStderr();
if (timeout) {
LOG.warn("Validation of " + executable + " failed with a timeout");
}
if (exitCode != 0) {
LOG.warn("Validation of " + executable + " failed with a non-zero exit code: " + exitCode);
}
if (!stderr.isEmpty()) {
LOG.warn("Validation of " + executable + " failed with a non-empty error output: " + stderr);
}
return !timeout && exitCode == 0 && stderr.isEmpty();
}
catch (Throwable t) {
LOG.warn(t);
return false;
}
}
示例3: 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());
}
示例4: createVirtualEnv
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
public static String createVirtualEnv(@NotNull String destinationDir, String version) throws ExecutionException {
final String condaExecutable = PyCondaPackageService.getCondaExecutable();
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,
"python=" + version, "-y");
final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);
final Process process = commandLine.createProcess();
final CapturingProcessHandler handler = new CapturingProcessHandler(process);
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;
}
示例5: addRepository
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Override
public void addRepository(String repositoryUrl) {
final String conda = PyCondaPackageService.getCondaExecutable();
final ArrayList<String> parameters = Lists.newArrayList(conda, "config", "--add", "channels", repositoryUrl, "--force");
final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);
try {
final Process process = commandLine.createProcess();
final CapturingProcessHandler handler = new CapturingProcessHandler(process);
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 add repository " + message);
}
PyCondaPackageService.getInstance().addChannel(repositoryUrl);
}
catch (ExecutionException e) {
LOG.warn("Failed to add repository");
}
}
示例6: removeRepository
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Override
public void removeRepository(String repositoryUrl) {
final String conda = PyCondaPackageService.getCondaExecutable();
final ArrayList<String> parameters = Lists.newArrayList(conda, "config", "--remove", "channels", repositoryUrl, "--force");
final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);
try {
final Process process = commandLine.createProcess();
final CapturingProcessHandler handler = new CapturingProcessHandler(process);
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");
}
}
示例7: 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;
}
示例8: 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());
}
}
示例9: runHelperWithArgs
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Nullable
private static TheRRunResult runHelperWithArgs(@NotNull final String helper, @NotNull final String... args) {
final String interpreterPath = TheRInterpreterService.getInstance().getInterpreterPath();
if (StringUtil.isEmptyOrSpaces(interpreterPath)) {
LOG.info("Path to interpreter didn't set");
return null;
}
final ArrayList<String> command = Lists.newArrayList(interpreterPath, " --slave", "-f ", TheRHelpersLocator.getHelperPath(helper),
" --args");
Collections.addAll(command, args);
try {
final Process process = new GeneralCommandLine(command).createProcess();
final CapturingProcessHandler processHandler = new CapturingProcessHandler(process, null, StringUtil.join(command, " "));
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 new TheRRunResult(StringUtil.join(command, " "), output);
}
catch (ExecutionException e) {
LOG.error(e.getMessage());
}
return null;
}
示例10: runSkeletonGeneration
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public static void runSkeletonGeneration() {
final String path = TheRInterpreterService.getInstance().getInterpreterPath();
if (StringUtil.isEmptyOrSpaces(path)) return;
final String helperPath = TheRHelpersLocator.getHelperPath(R_GENERATOR);
try {
final String skeletonsPath = getSkeletonsPath(path);
final File skeletonsDir = new File(skeletonsPath);
if (!skeletonsDir.exists() && !skeletonsDir.mkdirs()) {
LOG.error("Can't create skeleton dir " + String.valueOf(skeletonsPath));
}
final String commandLine = path + " --slave -f " + helperPath + " --args " + skeletonsPath;
final Process process = Runtime.getRuntime().exec(commandLine);
final CapturingProcessHandler processHandler = new CapturingProcessHandler(process, null, commandLine);
final ProcessOutput output = processHandler.runProcess(MINUTE * 5);
if (output.getExitCode() != 0) {
LOG.error("Failed to generate skeletons. Exit code: " + output.getExitCode());
LOG.error(output.getStderrLines());
}
}
catch (IOException e) {
LOG.error(e);
}
}
示例11: identifyVersion
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
public static GitVersion identifyVersion(String gitExecutable) throws TimeoutException, ExecutionException, ParseException {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(gitExecutable);
commandLine.addParameter("--version");
CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
ProcessOutput result = handler.runProcess(30 * 1000);
if (result.isTimeout()) {
throw new TimeoutException("Couldn't identify the version of Git - stopped by timeout.");
}
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());
}
示例12: testPath
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
private void testPath(final DatabaseVendor databaseVendor) {
ProcessOutput processOutput;
try {
processOutput = ProgressManager.getInstance().runProcessWithProgressSynchronously(new ThrowableComputable<ProcessOutput, Exception>() {
@Override
public ProcessOutput compute() throws Exception {
return checkShellPath(databaseVendor, getShellPath());
}
}, "Testing " + databaseVendor.name + " CLI Executable...", true, NoSqlConfigurable.this.project);
} catch (ProcessCanceledException pce) {
return;
} catch (Exception e) {
Messages.showErrorDialog(mainPanel, e.getMessage(), "Something wrong happened");
return;
}
if (processOutput != null && processOutput.getExitCode() == 0) {
Messages.showInfoMessage(mainPanel, processOutput.getStdout(), databaseVendor.name + " CLI Path Checked");
}
}
示例13: getExecutableVersionOutput
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
private String[] getExecutableVersionOutput(String sdkHome)
{
final String exePath = getTopLevelExecutable(sdkHome).getAbsolutePath();
final ProcessOutput processOutput;
try
{
processOutput = LuaSystemUtil.getProcessOutput(sdkHome, exePath, "-v");
}
catch(final ExecutionException e)
{
return null;
}
if(processOutput.getExitCode() != 0)
{
return null;
}
final String stdout = processOutput.getStderr().trim();
if(stdout.isEmpty())
{
return null;
}
return stdout.split(" ");
}
示例14: getVersionString
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Nullable
@Override
public String getVersionString(@NotNull final String sdkPath) {
final String exePath = getCompilerExecutable(sdkPath).getAbsolutePath();
final ProcessOutput processOutput;
try {
processOutput = DeftSystemUtil.getProcessOutput(sdkPath, exePath, "-shortversion");
} catch (final ExecutionException e) {
return null;
}
if (processOutput.getExitCode() != 0) {
return null;
}
final String stdout = processOutput.getStdout().trim();
if (stdout.isEmpty()) {
return null;
}
return stdout;
}
示例15: getBinaryProcessOutput
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
protected ProcessOutput getBinaryProcessOutput(VirtualFile interpreterExecutable, VirtualFile container) {
// Convert the virtual file of the container back to a path string
String workingDirectory = container.getCanonicalPath();
if (workingDirectory == null)
return null;
String exePath = interpreterExecutable.getCanonicalPath();
if (exePath == null)
return null;
// Execute the process and ask for its version number
ProcessOutput processOutput;
try {
processOutput = LuaSystemUtil.getProcessOutput(
workingDirectory,
exePath,
"--version"
);
if (processOutput.getExitCode() != 0)
throw new ExecutionException("Invalid parameter");
} catch (final ExecutionException e1) {
try {
processOutput = LuaSystemUtil.getProcessOutput(
workingDirectory,
exePath,
"-v"
);
} catch (final ExecutionException e2) {
return null;
}
}
return processOutput;
}