use of com.intellij.execution.ExecutionException in project intellij-elixir by KronicDeth.
the class ElixirXDebugProcess method setUpElixirDebuggerCodePath.
@NotNull
private static List<String> setUpElixirDebuggerCodePath() throws ExecutionException {
LOG.debug("Setting up debugger environment.");
try {
String[] files = { "Elixir.Mix.Tasks.IntellijElixir.DebugTask.beam", "Elixir.IntellijElixir.DebugServer.beam" };
File tempDirectory = FileUtil.createTempDirectory("intellij_elixir_debugger", null);
LOG.debug("Debugger elixir files will be put to: " + tempDirectory.getPath());
for (String file : files) {
copyFileTo(file, tempDirectory);
}
LOG.debug("Debugger elixir files were copied successfully.");
return Arrays.asList("-pa", tempDirectory.getPath());
} catch (IOException e) {
throw new ExecutionException("Failed to setup debugger environment", e);
}
}
use of com.intellij.execution.ExecutionException in project intellij-elixir by KronicDeth.
the class MixBuilder method runMix.
private static void runMix(@NotNull String elixirPath, @NotNull String mixPath, @Nullable String contentRootPath, boolean addDebugInfo, @NotNull CompileContext context) throws ProjectBuildException {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.withWorkDirectory(contentRootPath);
commandLine.setExePath(elixirPath);
commandLine.addParameter(mixPath);
commandLine.addParameter("compile");
if (!addDebugInfo) {
commandLine.addParameter("--no-debug-info");
}
Process process;
try {
process = commandLine.createProcess();
} catch (ExecutionException e) {
throw new ProjectBuildException("Failed to run mix.", e);
}
BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset());
ProcessAdapter adapter = new ElixirCompilerProcessAdapter(context, NAME, commandLine.getWorkDirectory().getPath());
handler.addProcessListener(adapter);
handler.startNotify();
handler.waitFor();
}
use of com.intellij.execution.ExecutionException in project azure-tools-for-java by Microsoft.
the class SparkBatchJobDebuggerRunner method execute.
@Override
protected void execute(@NotNull ExecutionEnvironment environment, @Nullable Callback callback, @NotNull RunProfileState state) throws ExecutionException {
SparkBatchJobSubmissionState submissionState = (SparkBatchJobSubmissionState) state;
SparkSubmitModel submitModel = submissionState.getSubmitModel();
SparkSubmissionParameter submissionParameter = submitModel.getSubmissionParameter();
IClusterDetail clusterDetail = submitModel.getSelectedClusterDetail();
Map<String, String> postEventProperty = new HashMap<>();
submitModel.buildArtifactObservable(submissionParameter.getArtifactName()).flatMap((artifact) -> submitModel.deployArtifactObservable(artifact, clusterDetail).subscribeOn(Schedulers.io())).map((selectedClusterDetail) -> {
// Create Batch Spark Debug Job
try {
return submitModel.tryToCreateBatchSparkDebugJob(selectedClusterDetail);
} catch (Exception e) {
HDInsightUtil.setJobRunningStatus(submitModel.getProject(), false);
throw Exceptions.propagate(e);
}
}).flatMap((remoteDebugJob) -> startDebuggerObservable(environment, callback, submissionState, remoteDebugJob).subscribeOn(Schedulers.computation()).zipWith(submitModel.jobLogObservable(remoteDebugJob.getBatchId(), clusterDetail).subscribeOn(Schedulers.computation()), (session, ignore) -> session).doOnError(err -> {
try {
HDInsightUtil.showErrorMessageOnSubmissionMessageWindow(submitModel.getProject(), "Error : Spark batch debugging job is killed, got exception " + err);
remoteDebugJob.killBatchJob();
HDInsightUtil.setJobRunningStatus(submitModel.getProject(), false);
} catch (IOException ignore) {
}
})).subscribe(sparkBatchDebugSession -> {
HDInsightUtil.showInfoOnSubmissionMessageWindow(submitModel.getProject(), "Info : Debugging Spark batch job in cluster is done.");
sparkBatchDebugSession.close();
HDInsightUtil.setJobRunningStatus(submitModel.getProject(), false);
postEventProperty.put("IsSubmitSucceed", "true");
AppInsightsClient.create(HDInsightBundle.message("SparkRunConfigDebugButtonClick"), null, postEventProperty);
}, (throwable) -> {
// set the running flag to false
HDInsightUtil.setJobRunningStatus(submitModel.getProject(), false);
String errorMessage;
if (throwable instanceof CompositeException) {
CompositeException exceptions = (CompositeException) throwable;
errorMessage = exceptions.getExceptions().stream().map(Throwable::getMessage).collect(Collectors.joining("; "));
} else {
errorMessage = throwable.getMessage();
}
HDInsightUtil.showErrorMessageOnSubmissionMessageWindow(submitModel.getProject(), "Error : Spark batch Job remote debug failed, got exception: " + errorMessage);
postEventProperty.put("IsSubmitSucceed", "false");
postEventProperty.put("SubmitFailedReason", errorMessage.substring(0, 50));
AppInsightsClient.create(HDInsightBundle.message("SparkRunConfigDebugButtonClick"), null, postEventProperty);
});
}
use of com.intellij.execution.ExecutionException in project intellij-elixir by KronicDeth.
the class ExtProcessUtil method execAndGetFirstLine.
@NotNull
public static ExtProcessOutput execAndGetFirstLine(long timeout, @NotNull String... command) {
try {
final Process cmdRunner = new GeneralCommandLine(command).createProcess();
ExecutorService singleTreadExecutor = Executors.newSingleThreadExecutor();
try {
Future<ExtProcessOutput> cmdRunnerFuture = singleTreadExecutor.submit(new Callable<ExtProcessOutput>() {
@Override
public ExtProcessOutput call() throws Exception {
cmdRunner.waitFor();
String stdOut = readLine(cmdRunner.getInputStream());
String stdErr = readLine(cmdRunner.getErrorStream());
return new ExtProcessOutput(stdOut, stdErr);
}
});
try {
return cmdRunnerFuture.get(timeout, TimeUnit.MILLISECONDS);
} catch (Exception e) {
// Suppress
}
cmdRunnerFuture.cancel(true);
} finally {
singleTreadExecutor.shutdown();
}
} catch (ExecutionException e) {
// Suppress
}
return new ExtProcessOutput("", "");
}
use of com.intellij.execution.ExecutionException in project intellij-elixir by KronicDeth.
the class MixProjectRootStep method fetchDependencies.
private static void fetchDependencies(@NotNull final VirtualFile projectRoot, @NotNull final String mixPath) {
final Project project = ProjectImportBuilder.getCurrentProject();
String sdkPath = project != null ? ElixirSdkType.getSdkPath(project) : null;
final String elixirPath = sdkPath != null ? JpsElixirSdkType.getScriptInterpreterExecutable(sdkPath).getAbsolutePath() : JpsElixirSdkType.getExecutableFileName(JpsElixirSdkType.SCRIPT_INTERPRETER);
ProgressManager.getInstance().run(new Task.Modal(project, "Fetching dependencies", true) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
indicator.setIndeterminate(true);
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.withWorkDirectory(projectRoot.getCanonicalPath());
commandLine.setExePath(elixirPath);
commandLine.addParameter(mixPath);
commandLine.addParameter("deps.get");
try {
OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), commandLine.getPreparedCommandLine(Platform.current()));
handler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
String text = event.getText();
indicator.setText2(text);
}
});
ProcessTerminatedListener.attach(handler);
handler.startNotify();
handler.waitFor();
indicator.setText2("Refreshing");
} catch (ExecutionException e) {
LOG.warn(e);
}
}
});
}
Aggregations