use of com.intellij.execution.OutputListener in project intellij-community by JetBrains.
the class PythonTask method runNoConsole.
/**
* Runs task with out console
* @return stdout
* @throws ExecutionException in case of error. Consider using {@link com.intellij.execution.util.ExecutionErrorDialog}
*/
@NotNull
public final String runNoConsole() throws ExecutionException {
final ProcessHandler process = createProcess(new HashMap<>());
final OutputListener listener = new OutputListener();
process.addProcessListener(listener);
process.startNotify();
process.waitFor(TIMEOUT_TO_WAIT_FOR_TASK);
final Output output = listener.getOutput();
final int exitCode = output.getExitCode();
if (exitCode == 0) {
return output.getStdout();
}
throw new ExecutionException(String.format("Error on python side. " + "Exit code: %s, err: %s out: %s", exitCode, output.getStderr(), output.getStdout()));
}
use of com.intellij.execution.OutputListener in project flutter-intellij by flutter.
the class FlutterModuleBuilder method commitModule.
@Nullable
@Override
public Module commitModule(@NotNull Project project, @Nullable ModifiableModuleModel model) {
final String basePath = getModuleFileDirectory();
if (basePath == null) {
Messages.showErrorDialog("Module path not set", "Internal Error");
return null;
}
final VirtualFile baseDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(basePath);
if (baseDir == null) {
Messages.showErrorDialog("Unable to determine Flutter project directory", "Internal Error");
return null;
}
final FlutterSdk sdk = getFlutterSdk();
if (sdk == null) {
Messages.showErrorDialog("Flutter SDK not found", "Error");
return null;
}
final OutputListener listener = new OutputListener();
final PubRoot root = runFlutterCreateWithProgress(baseDir, sdk, project, listener, getAdditionalSettings());
if (root == null) {
final String stderr = listener.getOutput().getStderr();
final String msg = stderr.isEmpty() ? "Flutter create command was unsuccessful" : stderr;
final int code = FlutterMessages.showDialog(project, msg, "Project Creation Error", new String[] { "Run Flutter Doctor", "Cancel" }, 0);
if (code == 0) {
new FlutterDoctorAction().startCommand(project, sdk, null);
}
return null;
}
FlutterSdkUtil.updateKnownSdkPaths(sdk.getHomePath());
// Create the Flutter module. This indirectly calls setupRootModule, etc.
final Module flutter = super.commitModule(project, model);
if (flutter == null) {
return null;
}
FlutterModuleUtils.autoShowMain(project, root);
addAndroidModule(project, model, basePath, flutter.getName());
return flutter;
}
use of com.intellij.execution.OutputListener in project flutter-intellij by flutter.
the class FlutterSmallIDEProjectGenerator method generateProject.
public static void generateProject(@NotNull Project project, @NotNull VirtualFile baseDir, @NotNull String flutterSdkPath, @NotNull Module module, @NotNull FlutterCreateAdditionalSettings settings) {
final FlutterSdk sdk = FlutterSdk.forPath(flutterSdkPath);
if (sdk == null) {
FlutterMessages.showError("Error creating project", flutterSdkPath + " is not a valid Flutter SDK");
return;
}
FlutterUtils.disableGradleProjectMigrationNotification(project);
// Run "flutter create".
final OutputListener listener = new OutputListener();
final PubRoot root = sdk.createFiles(baseDir, module, listener, settings);
if (root == null) {
final String stderr = listener.getOutput().getStderr();
final String msg = stderr.isEmpty() ? "Flutter create command was unsuccessful" : stderr;
FlutterMessages.showError("Error creating project", msg);
return;
}
final Runnable runnable = () -> applyDartModule(sdk, project, module, root);
try {
TransactionGuard.getInstance().submitTransactionAndWait(runnable);
} catch (ProcessCanceledException e) {
LOG.error(e);
}
}
Aggregations