@NotNull public static com.intellij.execution.process.ProcessOutput getProcessOutput(int timeout, @Nullable String workDir, @NotNull String exePath, @NotNull String... arguments) throws ExecutionException{ if(workDir == null || !new File(workDir).isDirectory() || !new File(exePath).canExecute()){ return new com.intellij.execution.process.ProcessOutput(); } GeneralCommandLine cmd = new GeneralCommandLine().withCharset(Charsets.UTF_8); cmd.withWorkDirectory(workDir); cmd.setExePath(exePath); cmd.addParameters(arguments); return execute(cmd, timeout); }
@NotNull public GeneralCommandLine createCommandLine() throws ExecutionException { if (myGoRoot == null) { throw new ExecutionException("Sdk is not set or Sdk home path is empty for module"); } GeneralCommandLine commandLine = !myPtyDisabled && PtyCommandLine.isEnabled() ? new PtyCommandLine() : new GeneralCommandLine(); commandLine.setExePath(ObjectUtils.notNull(myExePath, GoSdkService.getGoExecutablePath(myGoRoot))); commandLine.getEnvironment().putAll(myExtraEnvironment); commandLine.getEnvironment().put(GoConstants.GO_ROOT, StringUtil.notNullize(myGoRoot)); commandLine.getEnvironment().put(GoConstants.GO_PATH, StringUtil.notNullize(myGoPath)); if (myVendoringEnabled != null) { commandLine.getEnvironment().put(GoConstants.GO_VENDORING_EXPERIMENT, myVendoringEnabled ? "1" : "0"); } Collection<String> paths = ContainerUtil.newArrayList(); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(commandLine.getEnvironment().get(GoConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(EnvironmentUtil.getValue(GoConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(myEnvPath, true)); commandLine.getEnvironment().put(GoConstants.PATH, StringUtil.join(paths, File.pathSeparator)); commandLine.withWorkDirectory(myWorkDirectory); commandLine.addParameters(myParameterList.getList()); commandLine.withParentEnvironmentType(myParentEnvironmentType); commandLine.withCharset(CharsetToolkit.UTF8_CHARSET); return commandLine; }
@NotNull public GeneralCommandLine createCommandLine() throws ExecutionException { GeneralCommandLine commandLine = !myPtyDisabled && PtyCommandLine.isEnabled() ? new PtyCommandLine() : new GeneralCommandLine(); commandLine.setExePath(ObjectUtils.notNull(myExePath, ObjectUtils.notNull(BallerinaSdkService .getBallerinaExecutablePath(myBallerinaPath)))); commandLine.getEnvironment().putAll(myExtraEnvironment); //Todo - Add BALLERINA_REPOSITORY // commandLine.getEnvironment().put(BallerinaConstants.BALLERINA_REPOSITORY, // StringUtil.notNullize(myBallerinaPath)); Collection<String> paths = ContainerUtil.newArrayList(); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(commandLine.getEnvironment().get( BallerinaConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(EnvironmentUtil.getValue(BallerinaConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(myEnvPath, true)); commandLine.getEnvironment().put(BallerinaConstants.PATH, StringUtil.join(paths, File.pathSeparator)); commandLine.withWorkDirectory(myWorkDirectory); commandLine.addParameters(myParameterList.getList()); commandLine.withParentEnvironmentType(myParentEnvironmentType); commandLine.withCharset(CharsetToolkit.UTF8_CHARSET); return commandLine; }
public static boolean checkMongoShellPath(String mongoShellPath) throws ExecutionException { if (isBlank(mongoShellPath)) { return false; } GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(mongoShellPath); commandLine.addParameter("--version"); CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset(), commandLine.getCommandLineString()); ProcessOutput result = handler.runProcess(15 * 1000); return result.getExitCode() == 0; }
public static GeneralCommandLine buildCommandLine(String shellPath, ServerConfiguration serverConfiguration, MongoDatabase database) { GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(shellPath); commandLine.addParameter(buildMongoUrl(serverConfiguration, database));
@NotNull private GeneralCommandLine createCommandLine() { GeneralCommandLine ret = new GeneralCommandLine(); if (SystemInfo.isWindows) { ret.setExePath(ExecUtil.getWindowsShellName()); ret.addParameters("/c", GeneralCommandLine.inescapableQuote(loginSsoCmd)); } else if (SystemInfo.isMac) { ret.setExePath(ExecUtil.getOpenCommandPath()); ret.addParameters("-a", loginSsoCmd); } else { ret.setExePath("/bin/sh"); ret.addParameters("-c", loginSsoCmd); } return ret; } }
String javaPath = jreHome + "bin" + File.separator + "java"; GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(javaPath); commandLine.addParameters("-Dfile.encoding=UTF-8", "-Dapple.awt.UIElement=true");
final GeneralCommandLine cmd = new GeneralCommandLine(); cmd.setExePath(dmdBinary.getAbsolutePath()); cmd.addParameter("--version");
commandLine.setExePath("cmd"); commandLine.addParameter("/c"); } else { commandLine.setExePath("/bin/sh"); commandLine.addParameter("-c");
public static Boolean isKnownGdb(String path) { try { GeneralCommandLine command = new GeneralCommandLine(); command.setExePath(path); command.addParameter("--version"); ProcessOutput output = new CapturingProcessHandler( command.createProcess(), Charset.defaultCharset(), command.getCommandLineString()).runProcess(); if (output.getExitCode() != 0) { LOG.error("gdb exited with invalid exit code: " + output.getExitCode()); return false; } String cmdOutput = output.getStdout(); return cmdOutput.contains("(GDB) 7.6") || cmdOutput.contains("(GDB) 7.4"); } catch (Exception e) { LOG.error("Exception while executing the process:", e); return false; } }
@Override protected Process createProcess() throws ExecutionException { String bashLocation = BashInterpreterDetection.instance().findBestLocation(); if (bashLocation == null) { throw new ExecutionException("Could not locate the bash executable"); } GeneralCommandLine commandLine = new GeneralCommandLine().withWorkDirectory(getWorkingDir()); commandLine.setExePath(bashLocation); return commandLine.createProcess(); }
commandLine.setExePath(path); final ParametersList parametersList = commandLine.getParametersList(); parametersList.addParametersString("-c");
public static Boolean isValidGdbPath(String path) { try { GeneralCommandLine command = new GeneralCommandLine(); command.setExePath(path); command.addParameter("--version"); ProcessOutput output = new CapturingProcessHandler( command.createProcess(), Charset.defaultCharset(), command.getCommandLineString()).runProcess(); if (output.getExitCode() != 0) { LOG.error("gdb exited with invalid exit code: " + output.getExitCode()); return false; } // TODO maybe we should warn the user that his GDB version is not the latest at time of writing (7.6.2) return output.getStdout().contains("GDB"); } catch (Exception e) { // LOG.error("Exception while executing the process:", e); return false; } } }
commandLine.setExePath(dubPath); final ParametersList parametersList = commandLine.getParametersList(); parametersList.addParametersString("--");
@NotNull public static GeneralCommandLine createCommandLine(String workingDir, BashRunConfiguration runConfig) { String interpreterPath; if (runConfig.isUseProjectInterpreter()) { interpreterPath = BashProjectSettings.storedSettings(runConfig.getProject()).getProjectInterpreter(); } else { interpreterPath = runConfig.getInterpreterPath(); } GeneralCommandLine cmd = new GeneralCommandLine(); cmd.setExePath(interpreterPath); cmd.getParametersList().addParametersString(runConfig.getInterpreterOptions()); cmd.addParameter(runConfig.getScriptName()); cmd.getParametersList().addParametersString(runConfig.getProgramParameters()); cmd.withWorkDirectory(workingDir); cmd.withParentEnvironmentType(runConfig.isPassParentEnvs() ? GeneralCommandLine.ParentEnvironmentType.CONSOLE : GeneralCommandLine.ParentEnvironmentType.NONE); cmd.withEnvironment(runConfig.getEnvs()); return cmd; }
cmd.setExePath(dscannerPath);
commandLine.setExePath(stylishPath); commandLine.getParametersList().addParametersString(stylishFlags);
public GeneralCommandLine getExecutableCommandLine(final DlangRunAppConfiguration config) throws ModuleNotFoundException, NoValidDlangSdkFound { final Module module = config.getConfigurationModule().getModule(); if (module == null) { throw new ModuleNotFoundException(); } final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); final Sdk sdk = moduleRootManager.getSdk(); if (sdk == null || !(sdk.getSdkType() instanceof DlangSdkType)) { throw new NoValidDlangSdkFound(); } final VirtualFile sourcesRoot = getSourceRoot(module); final GeneralCommandLine cmd = new GeneralCommandLine(); cmd.setExePath(getOutputFilePath(module)); if (StringUtil.isNotEmpty(config.getWorkDir())) { cmd.withWorkDirectory(config.getWorkDir()); } else { cmd.withWorkDirectory(sourcesRoot.getPath()); } if (StringUtil.isNotEmpty(config.getAdditionalParams())) { cmd.addParameters(splitArguments(config.getAdditionalParams())); } return cmd; }
return; commandLine.setExePath(stylishPath); commandLine.getParametersList().addParametersString(stylishFlags);
cmd.setExePath(dubPath);