use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class SendToMayaCommand method run.
public void run() {
try {
final ProcessHandler process = createRunInMayaProcessHandler();
new RunContentExecutor(myProject, process).withTitle(getTitle()).withRerun(() -> this.run()).withStop(() -> process.destroyProcess(), () -> !process.isProcessTerminated()).run();
} catch (ExecutionException e) {
Messages.showErrorDialog(myProject, e.getMessage(), getTitle());
}
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class SendToMayaCommand method createRunInMayaProcessHandler.
private ProcessHandler createRunInMayaProcessHandler() throws ExecutionException {
try {
final Socket socket = new Socket("127.0.0.1", myPythonCommandPort);
final SocketProcessHandler processHandler = new SocketProcessHandler(socket, getTitle());
try {
PrintWriter writer = new PrintWriter(new BufferedOutputStream(socket.getOutputStream()));
if (myScriptText != null) {
String[] lines = getScriptLines();
writeLines(writer, lines);
processHandler.notifyTextAvailable("Sent " + lines.length + " line" + (lines.length != 1 ? "s" : "") + " to command port " + myPythonCommandPort + "\n", ProcessOutputTypes.SYSTEM);
} else {
writeFile(writer, myFile);
processHandler.notifyTextAvailable("Sent " + myFile.getPath() + " to command port " + myPythonCommandPort + "\n", ProcessOutputTypes.SYSTEM);
}
writer.flush();
} catch (Exception e) {
if (!socket.isClosed()) {
socket.close();
}
throw new ExecutionException(e.getMessage());
}
return processHandler;
} catch (Exception e) {
throw new ExecutionException(e.getMessage());
}
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class KarmaServer method startServer.
private KillableColoredProcessHandler startServer(@NotNull KarmaServerSettings serverSettings) throws IOException {
GeneralCommandLine commandLine = new GeneralCommandLine();
serverSettings.getEnvData().configureCommandLine(commandLine, true);
commandLine.withWorkDirectory(serverSettings.getConfigurationFile().getParentFile());
commandLine.setExePath(serverSettings.getNodeInterpreter().getInterpreterSystemDependentPath());
File serverFile = myKarmaJsSourcesLocator.getServerAppFile();
//NodeCommandLineUtil.addNodeOptionsForDebugging(commandLine, Collections.emptyList(), 34598, true,
// serverSettings.getNodeInterpreter(), true);
commandLine.addParameter(serverFile.getAbsolutePath());
commandLine.addParameter("--karmaPackageDir=" + myServerSettings.getKarmaPackage().getSystemDependentPath());
commandLine.addParameter("--configFile=" + serverSettings.getConfigurationFilePath());
String browsers = serverSettings.getBrowsers();
if (!StringUtil.isEmptyOrSpaces(browsers)) {
commandLine.addParameter("--browsers=" + browsers);
}
if (myCoveragePeer != null) {
commandLine.addParameter("--coverageTempDir=" + myCoveragePeer.getCoverageTempDir());
}
if (serverSettings.isDebug()) {
commandLine.addParameter("--debug=true");
}
commandLine.setCharset(CharsetToolkit.UTF8_CHARSET);
KillableColoredProcessHandler processHandler;
try {
processHandler = new KillableColoredProcessHandler(commandLine);
} catch (ExecutionException e) {
throw new IOException("Can not start Karma server: " + commandLine.getCommandLineString(), e);
}
final int processHashCode = System.identityHashCode(processHandler.getProcess());
LOG.info("Karma server " + processHashCode + " started successfully: " + commandLine.getCommandLineString());
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(final ProcessEvent event) {
LOG.info("Karma server " + processHashCode + " terminated with exit code " + event.getExitCode());
Disposer.dispose(myDisposable);
fireOnTerminated(event.getExitCode());
}
});
ProcessTerminatedListener.attach(processHandler);
processHandler.setShouldDestroyProcessRecursively(true);
return processHandler;
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class JstdServer method start.
@NotNull
private static OSProcessHandler start(@NotNull JstdServerSettings settings, int id) throws IOException {
GeneralCommandLine commandLine = createCommandLine(settings);
OSProcessHandler processHandler;
try {
processHandler = new KillableColoredProcessHandler(commandLine);
} catch (ExecutionException e) {
throw new IOException("Cannot start " + formatName(id, null) + ".\nCommand: " + commandLine.getCommandLineString(), e);
}
LOG.info(formatName(id, processHandler.getProcess()) + " started successfully: " + commandLine.getCommandLineString());
ProcessTerminatedListener.attach(processHandler);
processHandler.setShouldDestroyProcessRecursively(true);
return processHandler;
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class Flexmojos4GenerateConfigTask method perform.
@Override
public void perform(Project project, MavenEmbeddersManager embeddersManager, MavenConsole console, final MavenProgressIndicator indicator) throws MavenProcessCanceledException {
final long start = System.currentTimeMillis();
this.indicator = indicator;
indicator.setText(FlexBundle.message("generating.flex.configs"));
try {
runGeneratorServer(MavenProjectsManager.getInstance(project), project);
writeProjects(project);
} catch (IOException e) {
showWarning(project, e.getMessage());
LOG.error(e);
} catch (ExecutionException e) {
showWarning(project, e.getMessage());
}
if (process == null) {
return;
}
//noinspection WhileLoopSpinsOnField
while (process != null) {
try {
//noinspection BusyWait
Thread.sleep(500);
} catch (InterruptedException ignored) {
break;
}
if (indicator.isCanceled()) {
LOG.warn("Generating flex configs canceled");
if (process != null) {
process.destroy();
}
break;
}
}
if (postTask != null) {
MavenUtil.invokeAndWait(project, postTask);
MavenUtil.invokeAndWaitWriteAction(project, () -> {
for (Map.Entry<Module, String> entry : myModuleToConfigFilePath.entrySet()) {
if (entry.getKey().isDisposed())
continue;
final VirtualFile configFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(entry.getValue());
if (configFile != null && !configFile.isDirectory()) {
Flexmojos3GenerateConfigTask.updateMainClass(entry.getKey(), configFile);
}
}
});
}
final long duration = System.currentTimeMillis() - start;
LOG.info("Generating flex configs took " + duration + " ms: " + duration / 60000 + " min " + (duration % 60000) / 1000 + "sec");
}
Aggregations