本文整理匯總了Java中com.intellij.execution.configurations.GeneralCommandLine.createProcess方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneralCommandLine.createProcess方法的具體用法?Java GeneralCommandLine.createProcess怎麽用?Java GeneralCommandLine.createProcess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.execution.configurations.GeneralCommandLine
的用法示例。
在下文中一共展示了GeneralCommandLine.createProcess方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
public void run() throws Exception
{
// Prepare and run node-command which will fetch settings.
GeneralCommandLine commandLine = createCommandLine();
Process process = commandLine.createProcess();
String input = readInputStream(process.getInputStream());
Gson gson = new GsonBuilder()
.registerTypeAdapter(DefaultValue.class, new DefaultValueDeserializer())
.create();
Type targetType = new TypeToken<List<SettingTreeNode>>() {}.getType();
List<SettingTreeNode> settings = gson.fromJson(input, targetType);
if (settings == null)
{
String error = readInputStream(process.getErrorStream());
String message = error.length() > 0 ? error : input;
throw new Exception("Error occured while fetching completions: " + message);
}
SettingContainer completions = new SettingContainer(settings);
CompletionPreloader.setCompletions(completions);
}
示例2: createVirtualEnv
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的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;
}
示例3: addRepository
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的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");
}
}
示例4: execute
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
protected synchronized void execute(GeneralCommandLine commandLine) throws AuthenticationException {
try {
commandLine.withParentEnvironmentType(ParentEnvironmentType.CONSOLE);
myProcess = commandLine.createProcess();
myErrThread = new ReadProcessThread(
new BufferedReader(new InputStreamReader(myProcess.getErrorStream(), EncodingManager.getInstance().getDefaultCharset()))) {
protected void textAvailable(String s) {
myErrorText.append(s);
myErrorRegistry.registerError(s);
myContainsError = true;
}
};
final Application application = ApplicationManager.getApplication();
myStdErrFuture = application.executeOnPooledThread(myErrThread);
myInputStream = myProcess.getInputStream();
myOutputStream = myProcess.getOutputStream();
waitForProcess(application);
}
catch (Exception e) {
closeInternal();
throw new AuthenticationException(e.getLocalizedMessage(), e);
}
}
示例5: runJython
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
public static ProcessOutput runJython(String workDir, String pythonPath, String... args) throws ExecutionException {
final SimpleJavaSdkType sdkType = new SimpleJavaSdkType();
final Sdk ideaJdk = sdkType.createJdk("tmp", SystemProperties.getJavaHome());
SimpleJavaParameters parameters = new SimpleJavaParameters();
parameters.setJdk(ideaJdk);
parameters.setMainClass("org.python.util.jython");
File jythonJar = new File(PythonHelpersLocator.getPythonCommunityPath(), "lib/jython.jar");
parameters.getClassPath().add(jythonJar.getPath());
parameters.getProgramParametersList().add("-Dpython.path=" + pythonPath + File.pathSeparator + workDir);
parameters.getProgramParametersList().addAll(args);
parameters.setWorkingDirectory(workDir);
final GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(sdkType.getVMExecutablePath(ideaJdk), parameters, false);
final CapturingProcessHandler processHandler = new CapturingProcessHandler(commandLine.createProcess());
return processHandler.runProcess();
}
示例6: callProtractor
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
private void callProtractor() {
try {
Config config = Config.getInstance(project);
if (config == null) {
return;
}
GeneralCommandLine command = getProtractorRunCommand(config);
Process p = command.createProcess();
if (project != null) {
ToolWindowManager manager = ToolWindowManager.getInstance(project);
String id = "Gherkin Runner";
TextConsoleBuilderFactory factory = TextConsoleBuilderFactory.getInstance();
TextConsoleBuilder builder = factory.createBuilder(project);
ConsoleView view = builder.getConsole();
ColoredProcessHandler handler = new ColoredProcessHandler(p, command.getPreparedCommandLine());
handler.startNotify();
view.attachToProcess(handler);
ToolWindow window = manager.getToolWindow(id);
Icon cucumberIcon = IconLoader.findIcon("/resources/icons/cucumber.png");
if (window == null) {
window = manager.registerToolWindow(id, true, ToolWindowAnchor.BOTTOM);
window.setIcon(cucumberIcon);
}
ContentFactory cf = window.getContentManager().getFactory();
Content c = cf.createContent(view.getComponent(), "Run " + (window.getContentManager().getContentCount() + 1), true);
window.getContentManager().addContent(c);
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
示例7: runProcess
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
private static ProcessOutput runProcess(@NotNull final GeneralCommandLine cl) throws ExecutionException {
final CapturingProcessHandler handler = new CapturingProcessHandler(cl.createProcess(), Charset.forName("UTF-8"));
final ProcessOutput result = handler.runProcess(20000);
if (result.isTimeout()) {
throw new ExecutionException("Process execution of [" + cl.getCommandLineString() + "] has timed out");
}
final String errorOutput = result.getStderr();
if (!StringUtil.isEmptyOrSpaces(errorOutput)) {
throw new ExecutionException(errorOutput);
}
return result;
}
示例8: createCheckProcess
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
Process createCheckProcess(@NotNull final Project project, @NotNull final String executablePath) throws ExecutionException {
final Sdk sdk = PythonSdkType.findPythonSdk(ModuleManager.getInstance(project).getModules()[0]);
PyEduPluginConfigurator configurator = new PyEduPluginConfigurator();
String testsFileName = configurator.getTestFileName();
if (myTask instanceof TaskWithSubtasks) {
testsFileName = FileUtil.getNameWithoutExtension(testsFileName);
int index = ((TaskWithSubtasks)myTask).getActiveSubtaskIndex();
testsFileName += EduNames.SUBTASK_MARKER + index + "." + FileUtilRt.getExtension(configurator.getTestFileName());
}
final File testRunner = new File(myTaskDir.getPath(), testsFileName);
myCommandLine = new GeneralCommandLine();
myCommandLine.withWorkDirectory(myTaskDir.getPath());
final Map<String, String> env = myCommandLine.getEnvironment();
final VirtualFile courseDir = project.getBaseDir();
if (courseDir != null) {
env.put(PYTHONPATH, courseDir.getPath());
}
if (sdk != null) {
String pythonPath = sdk.getHomePath();
if (pythonPath != null) {
myCommandLine.setExePath(pythonPath);
myCommandLine.addParameter(testRunner.getPath());
myCommandLine.addParameter(FileUtil.toSystemDependentName(executablePath));
return myCommandLine.createProcess();
}
}
return null;
}
示例9: getState
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
final CommandLineState state = new CommandLineState(environment) {
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
GoalRuntime runtime = GoalRuntime.instance;
System.out.println("runtime is created");
final GeneralCommandLine line = new GeneralCommandLine();
line.setRedirectErrorStream(true);
line.setExePath("java");
line.addParameters("-cp","-debug", runtime.getRuntimePath().toString(),
"goal.tools.Run",
GoalDebugConfiguration.this.runFilePath);
System.out.println("command: " + line.getCommandLineString());
final Process process = line.createProcess();
return new OSProcessHandler(process, line.getCommandLineString());
}
};
return state;
}
示例10: getState
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor,
@NotNull ExecutionEnvironment environment)
throws ExecutionException {
final CommandLineState state = new CommandLineState(environment) {
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
final GoalRuntime runtime = GoalRuntime.getInstance();
//TODO: MAke sure that the preferences are used when running goal.
//final Path preferences = GoalRunConfiguration.this.writePreferences();
final GeneralCommandLine line = new GeneralCommandLine();
line.setRedirectErrorStream(true);
line.setExePath("java");
line.addParameters(
"-cp", runtime.getRuntimePath().toString(),
"goal.tools.Run",
//preferences.toString(),
GoalRunConfiguration.this.runFilePath
);
System.out.println("command: " + line.getCommandLineString());
final Process process = line.createProcess();
return new OSProcessHandler(process, line.getCommandLineString());
}
};
return state;
}
示例11: startProcess
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
GeneralCommandLine commandLine = generateCommandLine();
OSProcessHandler osProcessHandler =
new LuaProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
ProcessTerminatedListener.attach(osProcessHandler, runConfiguration.getProject());
return osProcessHandler;
}
示例12: execute
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
@NotNull
public static ProcessOutput execute(@NotNull GeneralCommandLine commandLine, int timeoutInMilliseconds) throws ExecutionException {
LOG.info("Running node command: " + commandLine.getCommandLineString());
Process process = commandLine.createProcess();
OSProcessHandler processHandler = new ColoredProcessHandler(process, commandLine.getCommandLineString(), Charsets.UTF_8);
final ProcessOutput output = new ProcessOutput();
processHandler.addProcessListener(new ProcessAdapter() {
public void onTextAvailable(ProcessEvent event, Key outputType) {
if (outputType.equals(ProcessOutputTypes.STDERR)) {
output.appendStderr(event.getText());
} else if (!outputType.equals(ProcessOutputTypes.SYSTEM)) {
output.appendStdout(event.getText());
}
}
});
processHandler.startNotify();
if (processHandler.waitFor(timeoutInMilliseconds)) {
output.setExitCode(process.exitValue());
} else {
processHandler.destroyProcess();
output.setTimeout();
}
if (output.isTimeout()) {
throw new ExecutionException("Command '" + commandLine.getCommandLineString() + "' is timed out.");
}
return output;
}
示例13: doLaunch
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
private boolean doLaunch(@Nullable String url,
@NotNull List<String> command,
@Nullable WebBrowser browser,
@Nullable Project project,
@NotNull String[] additionalParameters,
@Nullable Runnable launchTask) {
GeneralCommandLine commandLine = new GeneralCommandLine(command);
if (url != null && url.startsWith("jar:")) {
return false;
}
if (url != null) {
commandLine.addParameter(url);
}
final BrowserSpecificSettings browserSpecificSettings = browser == null ? null : browser.getSpecificSettings();
if (browserSpecificSettings != null) {
commandLine.getEnvironment().putAll(browserSpecificSettings.getEnvironmentVariables());
}
addArgs(commandLine, browserSpecificSettings, additionalParameters);
try {
Process process = commandLine.createProcess();
checkCreatedProcess(browser, project, commandLine, process, launchTask);
return true;
}
catch (ExecutionException e) {
showError(e.getMessage(), browser, project, null, null);
return false;
}
}
示例14: show
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
public void show(DiffRequest request) {
saveContents(request);
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(getToolPath());
try {
commandLine.addParameters(getParameters(request));
commandLine.createProcess();
}
catch (Exception e) {
ExecutionErrorDialog.show(new ExecutionException(e.getMessage()),
DiffBundle.message("cant.launch.diff.tool.error.message"), request.getProject());
}
}
示例15: doExecute
import com.intellij.execution.configurations.GeneralCommandLine; //導入方法依賴的package包/類
@NotNull
private static OSProcessHandler doExecute(@NotNull String exePath,
@Nullable String workingDirectory,
@Nullable VirtualFile scriptFile,
String[] parameters,
@Nullable Charset charset) throws ExecutionException {
GeneralCommandLine commandLine = new GeneralCommandLine(exePath);
if (scriptFile != null) {
commandLine.addParameter(scriptFile.getPresentableUrl());
}
commandLine.addParameters(parameters);
if (workingDirectory != null) {
commandLine.setWorkDirectory(workingDirectory);
}
LOG.debug("Command line: ", commandLine.getCommandLineString());
LOG.debug("Command line env: ", commandLine.getEnvironment());
if (charset == null) {
charset = EncodingManager.getInstance().getDefaultCharset();
}
final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine.createProcess(),
commandLine.getCommandLineString(),
charset);
if (LOG.isDebugEnabled()) {
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
LOG.debug(outputType + ": " + event.getText());
}
});
}
return processHandler;
}