本文整理汇总了Java中com.intellij.execution.process.ProcessOutput.checkSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessOutput.checkSuccess方法的具体用法?Java ProcessOutput.checkSuccess怎么用?Java ProcessOutput.checkSuccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.process.ProcessOutput
的用法示例。
在下文中一共展示了ProcessOutput.checkSuccess方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateBuiltinSkeletons
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public void generateBuiltinSkeletons(@NotNull Sdk sdk) throws InvalidSdkException {
//noinspection ResultOfMethodCallIgnored
new File(mySkeletonsPath).mkdirs();
String binaryPath = sdk.getHomePath();
if (binaryPath == null) throw new InvalidSdkException("Broken home path for " + sdk.getName());
long startTime = System.currentTimeMillis();
final ProcessOutput runResult = getProcessOutput(
new File(binaryPath).getParent(),
new String[]{
binaryPath,
PythonHelpersLocator.getHelperPath(GENERATOR3),
"-d", mySkeletonsPath, // output dir
"-b", // for builtins
},
PythonSdkType.getVirtualEnvExtraEnv(binaryPath), MINUTE * 5
);
runResult.checkSuccess(LOG);
LOG.info("Rebuilding builtin skeletons took " + (System.currentTimeMillis() - startTime) + " ms");
}
示例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: loadProjectStructureFromTargets
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
private String loadProjectStructureFromTargets(
@NotNull Consumer<String> statusConsumer,
@Nullable ProcessAdapter processAdapter
) throws IOException, ExecutionException {
final File outputFile = FileUtil.createTempFile("pants_depmap_run", ".out");
final GeneralCommandLine command = getPantsExportCommand(outputFile, statusConsumer);
statusConsumer.consume("Resolving dependencies...");
PantsMetrics.markExportStart();
final ProcessOutput processOutput = getProcessOutput(command);
PantsMetrics.markExportEnd();
if (processOutput.getStdout().contains("no such option")) {
throw new ExternalSystemException("Pants doesn't have necessary APIs. Please upgrade your pants!");
}
if (processOutput.checkSuccess(LOG)) {
return FileUtil.loadFile(outputFile);
}
else {
throw new PantsExecutionException("Failed to update the project!", command.getCommandLineString("pants"), processOutput);
}
}
示例4: getExportResult
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
public static SimpleExportResult getExportResult(@NotNull String pantsExecutable) {
File pantsExecutableFile = new File(pantsExecutable);
SimpleExportResult cache = simpleExportCache.get(pantsExecutableFile);
if (cache != null) {
return cache;
}
final GeneralCommandLine commandline = PantsUtil.defaultCommandLine(pantsExecutable);
commandline.addParameters("--no-quiet", "export", PantsConstants.PANTS_CLI_OPTION_NO_COLORS);
try (TempFile tempFile = TempFile.create("pants_export_run", ".out")) {
commandline.addParameter(
String.format("%s=%s", PantsConstants.PANTS_CLI_OPTION_EXPORT_OUTPUT_FILE,
tempFile.getFile().getPath()));
final ProcessOutput processOutput = PantsUtil.getCmdOutput(commandline, null);
if (processOutput.checkSuccess(LOG)) {
SimpleExportResult result = parse(FileUtil.loadFile(tempFile.getFile()));
simpleExportCache.put(pantsExecutableFile, result);
return result;
}
}
catch (IOException | ExecutionException e) {
// Fall-through to handle outside the block.
}
throw new PantsException("Failed:" + commandline.getCommandLineString());
}
示例5: 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();
}
示例6: getSysPathsFromScript
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
public static List<String> getSysPathsFromScript(@NotNull String binaryPath) throws InvalidSdkException {
// to handle the situation when PYTHONPATH contains ., we need to run the syspath script in the
// directory of the script itself - otherwise the dir in which we run the script (e.g. /usr/bin) will be added to SDK path
GeneralCommandLine cmd = PythonHelper.SYSPATH.newCommandLine(binaryPath, Lists.<String>newArrayList());
final ProcessOutput runResult = PySdkUtil.getProcessOutput(cmd, new File(binaryPath).getParent(),
getVirtualEnvExtraEnv(binaryPath), MINUTE);
if (!runResult.checkSuccess(LOG)) {
throw new InvalidSdkException(String.format("Failed to determine Python's sys.path value:\nSTDOUT: %s\nSTDERR: %s",
runResult.getStdout(),
runResult.getStderr()));
}
return runResult.getStdoutLines();
}
示例7: listAllTargets
import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public static Collection<String> listAllTargets(@NotNull String projectPath) throws PantsException {
if (!PantsUtil.isBUILDFilePath(projectPath)) {
return Lists.newArrayList();
}
GeneralCommandLine cmd = PantsUtil.defaultCommandLine(projectPath);
try (TempFile tempFile = TempFile.create("list", ".out")) {
cmd.addParameters(
"list",
Paths.get(projectPath).getParent().toString() + ':',
String.format("%s=%s", PantsConstants.PANTS_CLI_OPTION_LIST_OUTPUT_FILE,
tempFile.getFile().getPath()
)
);
final ProcessOutput processOutput = PantsUtil.getCmdOutput(cmd, null);
if (processOutput.checkSuccess(LOG)) {
// output only exists if "list" task succeeds
final String output = FileUtil.loadFile(tempFile.getFile());
return Arrays.asList(output.split("\n"));
}
else {
List<String> errorLogs = Lists.newArrayList(
String.format("Could not list targets: Pants exited with status %d",
processOutput.getExitCode()),
String.format("argv: '%s'", cmd.getCommandLineString()),
"stdout:",
processOutput.getStdout(),
"stderr:",
processOutput.getStderr());
final String errorMessage = String.join("\n", errorLogs);
LOG.warn(errorMessage);
throw new PantsException(errorMessage);
}
}
catch (IOException | ExecutionException e) {
final String processCreationFailureMessage =
String.format("Could not execute command: '%s' due to error: '%s'",
cmd.getCommandLineString(),
e.getMessage());
LOG.warn(processCreationFailureMessage, e);
throw new PantsException(processCreationFailureMessage);
}
}