Search in sources :

Example 1 with RunProcessHandler

use of com.microsoft.intellij.RunProcessHandler in project azure-tools-for-java by Microsoft.

the class CreateWebAppAction method deploy.

@AzureOperation(name = "webapp.deploy_artifact", params = { "webapp.name()" }, type = AzureOperation.Type.ACTION)
private void deploy(final IWebApp webapp, final Path application, final Project project) {
    final AzureString title = title("webapp.deploy_artifact", webapp.name());
    final AzureTask<Void> task = new AzureTask<>(null, title, false, () -> {
        ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
        final RunProcessHandler processHandler = new RunProcessHandler();
        processHandler.addDefaultListener();
        final ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
        processHandler.startNotify();
        consoleView.attachToProcess(processHandler);
        AzureWebAppMvpModel.getInstance().deployArtifactsToWebApp(webapp, application.toFile(), true, processHandler);
    });
    AzureTaskManager.getInstance().runInModalAsObservable(task).single().subscribe((none) -> {
        this.notifyDeploymentSuccess(webapp);
    });
// let root exception handler to show the error.
}
Also used : ConsoleView(com.intellij.execution.ui.ConsoleView) RunProcessHandler(com.microsoft.intellij.RunProcessHandler) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 2 with RunProcessHandler

use of com.microsoft.intellij.RunProcessHandler in project azure-tools-for-java by Microsoft.

the class AzureRunProfileState method execute.

@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner programRunner) throws ExecutionException {
    final RunProcessHandler processHandler = new RunProcessHandler();
    processHandler.addDefaultListener();
    ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(this.project).getConsole();
    processHandler.startNotify();
    consoleView.attachToProcess(processHandler);
    final Operation operation = createOperation();
    final Disposable subscribe = Mono.fromCallable(() -> {
        try {
            operation.start();
            return this.executeSteps(processHandler, operation);
        } finally {
            // Once the operation done, whether success or not, `setText` should not throw new exception
            processHandler.setProcessTerminatedHandler(RunProcessHandler.DO_NOTHING);
        }
    }).subscribeOn(Schedulers.boundedElastic()).subscribe((res) -> {
        this.sendTelemetry(operation, null);
        this.onSuccess(res, processHandler);
    }, (err) -> {
        err.printStackTrace();
        this.sendTelemetry(operation, err);
        this.onFail(err, processHandler);
    });
    processHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(@NotNull ProcessEvent event) {
            subscribe.dispose();
        }
    });
    return new DefaultExecutionResult(consoleView, processHandler);
}
Also used : Disposable(reactor.core.Disposable) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) ConsoleView(com.intellij.execution.ui.ConsoleView) ProcessEvent(com.intellij.execution.process.ProcessEvent) RunProcessHandler(com.microsoft.intellij.RunProcessHandler) Operation(com.microsoft.azuretools.telemetrywrapper.Operation) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with RunProcessHandler

use of com.microsoft.intellij.RunProcessHandler in project azure-tools-for-java by Microsoft.

the class SpringCloudDeploymentConfigurationState method execute.

@Override
@Nullable
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner<?> runner) throws ExecutionException {
    final RunProcessHandler processHandler = new RunProcessHandler();
    processHandler.addDefaultListener();
    processHandler.startNotify();
    processHandler.setProcessTerminatedHandler(RunProcessHandler.DO_NOTHING);
    final ConsoleMessager messager = new ConsoleMessager(processHandler);
    final ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(this.project).getConsole();
    consoleView.attachToProcess(processHandler);
    final Disposable subscribe = Mono.fromCallable(() -> this.execute(messager)).doOnTerminate(processHandler::notifyComplete).subscribeOn(Schedulers.boundedElastic()).subscribe((res) -> messager.success("Deploy succeed!"), messager::error);
    processHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(@NotNull ProcessEvent event) {
            subscribe.dispose();
        }
    });
    return new DefaultExecutionResult(consoleView, processHandler);
}
Also used : Disposable(reactor.core.Disposable) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) ConsoleView(com.intellij.execution.ui.ConsoleView) ProcessEvent(com.intellij.execution.process.ProcessEvent) RunProcessHandler(com.microsoft.intellij.RunProcessHandler) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ConsoleView (com.intellij.execution.ui.ConsoleView)3 RunProcessHandler (com.microsoft.intellij.RunProcessHandler)3 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)2 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)2 ProcessEvent (com.intellij.execution.process.ProcessEvent)2 Nullable (org.jetbrains.annotations.Nullable)2 Disposable (reactor.core.Disposable)2 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)1 Operation (com.microsoft.azuretools.telemetrywrapper.Operation)1