com.intellij.execution.process.ProcessOutput Java Examples
The following examples show how to use
com.intellij.execution.process.ProcessOutput.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OSSPantsJavaExamplesIntegrationTest.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
private String[] getModulesNamesFromPantsDependencies(String targetName) throws ProjectBuildException { Optional<VirtualFile> pantsExe = PantsUtil.findPantsExecutable(myProject); assertTrue(pantsExe.isPresent()); final GeneralCommandLine commandLine = PantsUtil.defaultCommandLine(pantsExe.get().getPath()); commandLine.addParameters(PantsConstants.PANTS_CLI_OPTION_NO_COLORS); commandLine.addParameters("dependencies"); commandLine.addParameters(targetName); final Process process; try { process = commandLine.createProcess(); } catch (ExecutionException e) { throw new ProjectBuildException(e); } final CapturingProcessHandler processHandler = new CapturingAnsiEscapesAwareProcessHandler(process, commandLine.getCommandLineString()); ProcessOutput output = processHandler.runProcess(); String lines[] = output.getStdout().split("\\r?\\n"); Set<String> modules = new HashSet<>(); for (String l : lines) { modules.add(PantsUtil.getCanonicalModuleName(l)); } return modules.toArray(new String[modules.size()]); }
Example #2
Source File: SystemInfopageDocSource.java From BashSupport with Apache License 2.0 | 6 votes |
String callTextToHtml(final String infoPageData) throws IOException { if (txt2htmlExecutable == null) { //cheap fallback return "<html><body><pre>" + infoPageData + "</pre></body></html>"; } ProcessBuilder processBuilder = new ProcessBuilder(txt2htmlExecutable, "--infile", "-"); CapturingProcessHandler processHandler = new MyCapturingProcessHandler(processBuilder.start(), infoPageData, txt2htmlExecutable + " --inifile -"); ProcessOutput output = processHandler.runProcess(TIMEOUT_IN_MILLISECONDS); if (output.getExitCode() != 0) { return null; } return output.getStdout(); }
Example #3
Source File: SimpleExportResult.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@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()); }
Example #4
Source File: ExecUtil.java From intellij-haskforce with Apache License 2.0 | 6 votes |
/** * 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(); }
Example #5
Source File: NoSqlConfigurable.java From nosql4idea with Apache License 2.0 | 6 votes |
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"); } }
Example #6
Source File: PantsCompileOptionsExecutor.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@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); } }
Example #7
Source File: PantsCompileOptionsExecutor.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@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); } }
Example #8
Source File: SystemUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Execute the given command line, and return the process output as one result in a future. * <p> * This is a non-blocking equivalient to {@link ExecUtil#execAndGetOutput(GeneralCommandLine)}. */ public static CompletableFuture<ProcessOutput> execAndGetOutput(GeneralCommandLine cmd) { final CompletableFuture<ProcessOutput> future = new CompletableFuture<>(); AppExecutorUtil.getAppExecutorService().submit(() -> { try { final ProcessOutput output = ExecUtil.execAndGetOutput(cmd); future.complete(output); } catch (ExecutionException e) { future.completeExceptionally(e); } }); return future; }
Example #9
Source File: WindowsDefenderChecker.java From consulo with Apache License 2.0 | 6 votes |
private static Boolean parseWindowsDefenderProductState(ProcessOutput output) { final String[] lines = StringUtil.splitByLines(output.getStdout()); for (String line : lines) { if (line.startsWith("Windows Defender")) { final String productStateString = StringUtil.substringAfterLast(line, " "); int productState; try { productState = Integer.parseInt(productStateString); return (productState & 0x1000) != 0; } catch (NumberFormatException e) { LOG.info("Unexpected wmic output format: " + line); return null; } } } return false; }
Example #10
Source File: WindowsDefenderChecker.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private static Collection<String> getWindowsDefenderProperty(final String propertyName) { try { ProcessOutput output = ExecUtil.execAndGetOutput(new GeneralCommandLine("powershell", "-inputformat", "none", "-outputformat", "text", "-NonInteractive", "-Command", "Get-MpPreference | select -ExpandProperty \"" + propertyName + "\""), POWERSHELL_COMMAND_TIMEOUT_MS); if (output.getExitCode() == 0) { return output.getStdoutLines(); } else { LOG.warn("Windows Defender " + propertyName + " check exited with status " + output.getExitCode() + ": " + StringUtil.first(output.getStderr(), MAX_POWERSHELL_STDERR_LENGTH, false)); } } catch (ExecutionException e) { LOG.warn("Windows Defender " + propertyName + " check failed", e); } return null; }
Example #11
Source File: SystemUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Execute the given command line, and return the process output as one result in a future. * <p> * This is a non-blocking equivalient to {@link ExecUtil#execAndGetOutput(GeneralCommandLine)}. */ public static CompletableFuture<ProcessOutput> execAndGetOutput(GeneralCommandLine cmd) { final CompletableFuture<ProcessOutput> future = new CompletableFuture<>(); AppExecutorUtil.getAppExecutorService().submit(() -> { try { final ProcessOutput output = ExecUtil.execAndGetOutput(cmd); future.complete(output); } catch (ExecutionException e) { future.completeExceptionally(e); } }); return future; }
Example #12
Source File: SystemInfopageDocSource.java From BashSupport with Apache License 2.0 | 5 votes |
boolean infoFileExists(String commandName) throws IOException { //info -w locates an info file, exit status == 1 means that there is no info file ProcessBuilder processBuilder = new ProcessBuilder(infoExecutable, "-w", commandName); CapturingProcessHandler processHandler = new CapturingProcessHandler(processBuilder.start(), Charset.forName(CHARSET_NAME), infoExecutable + " -w " + commandName); ProcessOutput output = processHandler.runProcess(TIMEOUT_IN_MILLISECONDS); return output.getExitCode() == 0 && !output.getStdout().isEmpty(); }
Example #13
Source File: FlutterSettingsConfigurable.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void onVersionChanged() { final Workspace workspace = workspaceCache.get(); if (workspaceCache.isBazel()) { if (mySdkCombo.isEnabled()) { // The workspace is not null if workspaceCache.isBazel() is true. assert (workspace != null); mySdkCombo.setEnabled(false); mySdkCombo.getComboBox().getEditor() .setItem(workspace.getRoot().getPath() + '/' + workspace.getSdkHome() + " <set by bazel project>"); } } else { mySdkCombo.setEnabled(true); } final FlutterSdk sdk = FlutterSdk.forPath(getSdkPathText()); if (sdk == null) { // Clear the label out with a non-empty string, so that the layout doesn't give this element 0 height. myVersionLabel.setText(" "); fullVersionString = null; return; } final ModalityState modalityState = ModalityState.current(); final boolean trackWidgetCreationRecommended = sdk.getVersion().isTrackWidgetCreationRecommended(); myDisableTrackWidgetCreationCheckBox.setVisible(trackWidgetCreationRecommended); // TODO(devoncarew): Switch this to expecting json output. sdk.flutterVersion().start((ProcessOutput output) -> { final String fullVersionText = output.getStdout(); fullVersionString = fullVersionText; final String[] lines = StringUtil.splitByLines(fullVersionText); final String singleLineVersion = lines.length > 0 ? lines[0] : ""; ApplicationManager.getApplication().invokeLater(() -> updateVersionTextIfCurrent(sdk, singleLineVersion), modalityState); }, null); }
Example #14
Source File: SystemInfopageDocSource.java From BashSupport with Apache License 2.0 | 5 votes |
String loadPlainTextInfoPage(String commandName) throws IOException { ProcessBuilder processBuilder = new ProcessBuilder(infoExecutable, "-o", "-", commandName); CapturingProcessHandler processHandler = new CapturingProcessHandler(processBuilder.start(), Charset.forName(CHARSET_NAME), infoExecutable + " -o - " + commandName); ProcessOutput output = processHandler.runProcess(TIMEOUT_IN_MILLISECONDS); if (output.getExitCode() != 0) { return null; } return output.getStdout(); }
Example #15
Source File: VueGeneratorPeer.java From vue-for-idea with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void run() { try { ProcessOutput out = NodeRunner.execute(cmd, NodeRunner.TIME_OUT); callback.onEnd(out); } catch (ExecutionException e) { e.printStackTrace(); callback.onFaild(e); } }
Example #16
Source File: WindowsDefenderChecker.java From consulo with Apache License 2.0 | 5 votes |
public boolean runExcludePathsCommand(Project project, Collection<Path> paths) { try { final ProcessOutput output = ExecUtil.sudoAndGetOutput( new GeneralCommandLine("powershell", "-Command", "Add-MpPreference", "-ExclusionPath", StringUtil.join(paths, (path) -> StringUtil.wrapWithDoubleQuote(path.toString()), ",")), ""); return output.getExitCode() == 0; } catch (IOException | ExecutionException e) { UIUtil.invokeLaterIfNeeded(() -> Messages.showErrorDialog(project, DiagnosticBundle.message("virus.scanning.fix.failed", e.getMessage()), DiagnosticBundle.message("virus.scanning.fix.title"))); } return false; }
Example #17
Source File: PantsOptions.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
@NotNull private static PantsOptions execPantsOptions(@NotNull String pantsExecutable) { GeneralCommandLine exportCommandline = PantsUtil.defaultCommandLine(pantsExecutable); exportCommandline.addParameters("options", PantsConstants.PANTS_CLI_OPTION_NO_COLORS); try { ProcessOutput processOutput = PantsUtil.getCmdOutput(exportCommandline, null); return new PantsOptions(processOutput.getStdout()); } catch (ExecutionException e) { throw new PantsException("Failed:" + exportCommandline.getCommandLineString()); } }
Example #18
Source File: PantsUtil.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
public static ProcessOutput getCmdOutput( @NotNull GeneralCommandLine command, @Nullable ProcessAdapter processAdapter ) throws ExecutionException { final CapturingProcessHandler processHandler = new CapturingProcessHandler(command.createProcess(), Charset.defaultCharset(), command.getCommandLineString()); if (processAdapter != null) { processHandler.addProcessListener(processAdapter); } return processHandler.runProcess(); }
Example #19
Source File: PantsUtil.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
public static ProcessOutput getCmdOutput( @NotNull Process process, @NotNull String commandLineString, @Nullable ProcessAdapter processAdapter ) { final CapturingProcessHandler processHandler = new CapturingProcessHandler(process, Charset.defaultCharset(), commandLineString); if (processAdapter != null) { processHandler.addProcessListener(processAdapter); } return processHandler.runProcess(); }
Example #20
Source File: ESLintRunner.java From eslint-plugin with MIT License | 5 votes |
@NotNull public static Result lint(@NotNull String cwd, @NotNull String path, @NotNull ESLintProjectComponent component) { ESLintRunner.ESLintSettings settings = ESLintRunner.buildSettings(cwd, path, component); try { ProcessOutput output = ESLintRunner.lint(settings); return Result.processResults(output); } catch (ExecutionException e) { LOG.warn("Could not lint file", e); ESLintProjectComponent.showNotification("Error running ESLint inspection: " + e.getMessage() + "\ncwd: " + cwd + "\ncommand: " + component.eslintExecutable, NotificationType.WARNING); e.printStackTrace(); return Result.createError(e.getMessage()); } }
Example #21
Source File: ESLintRunner.java From eslint-plugin with MIT License | 5 votes |
@NotNull public static String runVersion(@NotNull ESLintSettings settings) throws ExecutionException { if (!new File(settings.eslintExecutablePath).exists()) { LOG.warn("Calling version with invalid eslint exe " + settings.eslintExecutablePath); return ""; } ProcessOutput out = version(settings); if (out.getExitCode() == 0) { return out.getStdout().trim(); } return ""; }
Example #22
Source File: Result.java From eslint-plugin with MIT License | 5 votes |
public static Result processResults(ProcessOutput output) { Result result = new Result(); result.errorOutput = output.getStderr(); try { List<FileResult> fileResults = parseInternal(output.getStdout()); if (fileResults != null && !fileResults.isEmpty()) { result.warns = fileResults.get(0).messages; } } catch (Exception e) { result.errorOutput = output.getStdout(); // result.errorOutput = e.toString(); } return result; }
Example #23
Source File: RailwaysUtils.java From railways with MIT License | 5 votes |
/** * Internally used method that runs rake task and gets its output. This * method should be called from backgroundable task. * * @param module Rails module for which rake task should be run. * @return Output of 'rake routes'. */ @Nullable public static ProcessOutput queryRakeRoutes(Module module, String routesTaskName, String railsEnv) { // Get root path of Rails application from module. RailsApp app = RailsApp.fromModule(module); if ((app == null) || (app.getRailsApplicationRoot() == null)) return null; String moduleContentRoot = app.getRailsApplicationRoot().getPresentableUrl(); ModuleRootManager mManager = ModuleRootManager.getInstance(module); Sdk sdk = mManager.getSdk(); if (sdk == null) { Notifications.Bus.notify(new Notification("Railways", "Railways Error", "Cannot update route list for '" + module.getName() + "' module, because its SDK is not set", NotificationType.ERROR) , module.getProject()); return null; } try { railsEnv = (railsEnv == null) ? "" : "RAILS_ENV=" + railsEnv; // Will work on IntelliJ platform since 2017.3 return RubyGemExecutionContext.create(sdk, "rake") .withModule(module) .withWorkingDirPath(moduleContentRoot) .withExecutionMode(new ExecutionModes.SameThreadMode()) .withArguments(routesTaskName, "--trace", railsEnv) .executeScript(); } catch (Exception e) { e.printStackTrace(); } return null; }
Example #24
Source File: NoSqlConfigurable.java From nosql4idea with Apache License 2.0 | 5 votes |
public ProcessOutput checkShellPath(DatabaseVendor databaseVendor, String shellPath) throws ExecutionException, TimeoutException { if (isBlank(shellPath)) { return null; } GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(shellPath); if (testParameter != null) { commandLine.addParameter(testParameter); } CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset()); ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); ProcessOutput result = indicator == null ? handler.runProcess(TIMEOUT_MS) : handler.runProcessWithProgressIndicator(indicator); if (result.isTimeout()) { throw new TimeoutException("Couldn't check " + databaseVendor.name + " CLI executable - stopped by timeout."); } else if (result.isCancelled()) { throw new ProcessCanceledException(); } else if (result.getExitCode() != 0 || !result.getStderr().isEmpty()) { throw new ExecutionException(String.format("Errors while executing %s. exitCode=%s errors: %s", commandLine.toString(), result.getExitCode(), result.getStderr())); } return result; }
Example #25
Source File: BuildifierUtil.java From buck with Apache License 2.0 | 5 votes |
/** * Reformats the given {@link String} using the given {@code buildifier} executable. * * <p>Note: this method only returns a non-empty {@link Optional} if reformatting results in a * change to the text. */ public static Optional<String> reformatText(String buildifierExecutable, String text) { try { GeneralCommandLine commandLine = new GeneralCommandLine() .withExePath(buildifierExecutable) .withParameters("-buildifier_disable=label", "-mode=print_if_changed") .withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE); CapturingProcessHandler capturingProcessHandler = new CapturingProcessHandler(commandLine); byte[] textBytes = text.getBytes(CharsetToolkit.UTF8_CHARSET); capturingProcessHandler.getProcessInput().write(textBytes); capturingProcessHandler.getProcessInput().flush(); capturingProcessHandler.getProcessInput().close(); ProcessOutput processOutput = capturingProcessHandler.runProcess(); if (!processOutput.isExitCodeSet() || processOutput.getExitCode() != 0) { LOGGER.debug( "Reformatting with buildifier failed [exit code=" + processOutput.getExitCode() + "] stderr: " + processOutput.getStderr()); return Optional.empty(); // failed to format text } String stdout = processOutput.getStdout(); if ("".equals(stdout)) { LOGGER.debug("No change to original text"); return Optional.empty(); // no change to original text } return Optional.of(stdout); } catch (IOException | ExecutionException e) { LOGGER.warn("Failed to reformat text using buildifier [" + buildifierExecutable + "]", e); return Optional.empty(); } }
Example #26
Source File: AbstractVcsTestCase.java From consulo with Apache License 2.0 | 5 votes |
private static void verify(final ProcessOutput runResult, final boolean sorted, final String... stdoutLines) { verify(runResult); final String[] lines = new LineTokenizer(runResult.getStdout()).execute(); if (sorted) { Arrays.sort(lines); } Assert.assertEquals(runResult.getStdout(), stdoutLines.length, lines.length); for(int i=0; i<stdoutLines.length; i++) { Assert.assertEquals(stdoutLines [i], compressWhitespace(lines [i])); } }
Example #27
Source File: Executor.java From consulo with Apache License 2.0 | 5 votes |
protected static String run(List<String> params) { final ProcessBuilder builder = new ProcessBuilder().command(params); builder.directory(ourCurrentDir()); builder.redirectErrorStream(true); Process clientProcess; try { clientProcess = builder.start(); } catch (IOException e) { throw new RuntimeException(e); } CapturingProcessHandler handler = new CapturingProcessHandler(clientProcess, CharsetToolkit.getDefaultSystemCharset(), StringUtil.join(params, " ")); ProcessOutput result = handler.runProcess(30*1000); if (result.isTimeout()) { throw new RuntimeException("Timeout waiting for the command execution. Command: " + StringUtil.join(params, " ")); } if (result.getExitCode() != 0) { log("{" + result.getExitCode() + "}"); } String stdout = result.getStdout().trim(); if (!StringUtil.isEmptyOrSpaces(stdout)) { log(stdout.trim()); } return stdout; }
Example #28
Source File: ExecutableValidator.java From consulo with Apache License 2.0 | 5 votes |
protected static boolean doCheckExecutable(@Nonnull String executable, @Nonnull List<String> processParameters) { try { GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(executable); commandLine.addParameters(processParameters); commandLine.setCharset(CharsetToolkit.getDefaultSystemCharset()); CapturingProcessHandler handler = new CapturingProcessHandler(commandLine); 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; } }
Example #29
Source File: EnvironmentAwareHost.java From consulo with Apache License 2.0 | 5 votes |
/** * @param commandLine commandLine to execute on this host * @return output of the corresponding process */ @Nonnull public ProcessOutput getProcessOutput(@Nonnull GeneralCommandLine commandLine) throws ExecutionException { BaseProcessHandler handler = getProcessHandler(commandLine); CapturingProcessRunner runner = new CapturingProcessRunner(handler); return runner.runProcess(); }
Example #30
Source File: WindowsDefenderChecker.java From consulo with Apache License 2.0 | 5 votes |
private static Boolean isWindowsDefenderActive() { try { ProcessOutput output = ExecUtil.execAndGetOutput(new GeneralCommandLine("wmic", "/Namespace:\\\\root\\SecurityCenter2", "Path", "AntivirusProduct", "Get", "displayName,productState"), WMIC_COMMAND_TIMEOUT_MS); if (output.getExitCode() == 0) { return parseWindowsDefenderProductState(output); } else { LOG.warn("wmic Windows Defender check exited with status " + output.getExitCode() + ": " + StringUtil.first(output.getStderr(), MAX_POWERSHELL_STDERR_LENGTH, false)); } } catch (ExecutionException e) { LOG.warn("wmic Windows Defender check failed", e); } return null; }