mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
Showing post install script errors AFTER the installation is completed
This commit is contained in:
@ -348,8 +348,11 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
|||||||
|
|
||||||
String desc = "<html><body>";
|
String desc = "<html><body>";
|
||||||
desc += "<b>" + selected.getName() + "</b>";
|
desc += "<b>" + selected.getName() + "</b>";
|
||||||
|
if (installed != null && installed.isReadOnly()) {
|
||||||
|
desc += " Built-In ";
|
||||||
|
}
|
||||||
|
|
||||||
String author = selected.getParentPackage().getMaintainer();
|
String author = selected.getParentPackage().getMaintainer();
|
||||||
String url = selected.getParentPackage().getWebsiteURL();
|
|
||||||
if (author != null && !author.isEmpty()) {
|
if (author != null && !author.isEmpty()) {
|
||||||
desc += " " + format("by <b>{0}</b>", author);
|
desc += " " + format("by <b>{0}</b>", author);
|
||||||
}
|
}
|
||||||
@ -364,6 +367,7 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
|||||||
}
|
}
|
||||||
desc = desc.substring(0, desc.lastIndexOf(',')) + ".<br />";
|
desc = desc.substring(0, desc.lastIndexOf(',')) + ".<br />";
|
||||||
|
|
||||||
|
String url = selected.getParentPackage().getWebsiteURL();
|
||||||
if (url != null && !url.isEmpty()) {
|
if (url != null && !url.isEmpty()) {
|
||||||
desc += " " + format("<a href=\"{0}\">More info</a>", url);
|
desc += " " + format("<a href=\"{0}\">More info</a>", url);
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ import processing.app.I18n;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static processing.app.I18n._;
|
import static processing.app.I18n._;
|
||||||
|
|
||||||
@ -158,17 +160,21 @@ public class ContributionManagerUI extends InstallerJDialog {
|
|||||||
installerThread = new Thread(new Runnable() {
|
installerThread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
List<String> errors = new LinkedList<String>();
|
||||||
try {
|
try {
|
||||||
setProgressVisible(true, _("Installing..."));
|
setProgressVisible(true, _("Installing..."));
|
||||||
installer.install(platformToInstall);
|
errors.addAll(installer.install(platformToInstall));
|
||||||
if (platformToRemove != null && !platformToRemove.isReadOnly()) {
|
if (platformToRemove != null && !platformToRemove.isReadOnly()) {
|
||||||
installer.remove(platformToRemove);
|
errors.addAll(installer.remove(platformToRemove));
|
||||||
}
|
}
|
||||||
onIndexesUpdated();
|
onIndexesUpdated();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
setProgressVisible(false, "");
|
setProgressVisible(false, "");
|
||||||
|
if (!errors.isEmpty()) {
|
||||||
|
setErrorMessage(errors.get(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -79,7 +79,8 @@ public class ContributionInstaller {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void install(ContributedPlatform platform) throws Exception {
|
public List<String> install(ContributedPlatform platform) throws Exception {
|
||||||
|
List<String> errors = new LinkedList<String>();
|
||||||
if (platform.isInstalled()) {
|
if (platform.isInstalled()) {
|
||||||
throw new Exception("Platform is already installed!");
|
throw new Exception("Platform is already installed!");
|
||||||
}
|
}
|
||||||
@ -117,7 +118,7 @@ public class ContributionInstaller {
|
|||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// Download interrupted... just exit
|
// Download interrupted... just exit
|
||||||
return;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContributedPackage pack = platform.getParentPackage();
|
ContributedPackage pack = platform.getParentPackage();
|
||||||
@ -140,7 +141,11 @@ public class ContributionInstaller {
|
|||||||
destFolder.mkdirs();
|
destFolder.mkdirs();
|
||||||
assert toolContrib.getDownloadedFile() != null;
|
assert toolContrib.getDownloadedFile() != null;
|
||||||
new ArchiveExtractor(BaseNoGui.getPlatform()).extract(toolContrib.getDownloadedFile(), destFolder, 1);
|
new ArchiveExtractor(BaseNoGui.getPlatform()).extract(toolContrib.getDownloadedFile(), destFolder, 1);
|
||||||
|
try {
|
||||||
executePostInstallScriptIfAny(destFolder);
|
executePostInstallScriptIfAny(destFolder);
|
||||||
|
} catch (IOException e) {
|
||||||
|
errors.add(_("Error running post install script"));
|
||||||
|
}
|
||||||
toolContrib.setInstalled(true);
|
toolContrib.setInstalled(true);
|
||||||
toolContrib.setInstalledFolder(destFolder);
|
toolContrib.setInstalledFolder(destFolder);
|
||||||
progress.stepDone();
|
progress.stepDone();
|
||||||
@ -159,6 +164,8 @@ public class ContributionInstaller {
|
|||||||
|
|
||||||
progress.setStatus(_("Installation completed!"));
|
progress.setStatus(_("Installation completed!"));
|
||||||
onProgress(progress);
|
onProgress(progress);
|
||||||
|
|
||||||
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executePostInstallScriptIfAny(File folder) throws IOException {
|
private void executePostInstallScriptIfAny(File folder) throws IOException {
|
||||||
@ -184,14 +191,15 @@ public class ContributionInstaller {
|
|||||||
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
||||||
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
|
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
|
||||||
Executor executor = new CollectStdOutStdErrExecutor(stdout, stderr);
|
Executor executor = new CollectStdOutStdErrExecutor(stdout, stderr);
|
||||||
|
executor.setWorkingDirectory(folder);
|
||||||
executor.execute(new CommandLine(postInstallScript));
|
executor.execute(new CommandLine(postInstallScript));
|
||||||
|
|
||||||
System.out.write(stdout.toByteArray());
|
System.out.write(stdout.toByteArray());
|
||||||
System.err.write(stderr.toByteArray());
|
System.err.write(stderr.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(ContributedPlatform platform) {
|
public List<String> remove(ContributedPlatform platform) {
|
||||||
|
List<String> errors = new LinkedList<String>();
|
||||||
FileUtils.recursiveDelete(platform.getInstalledFolder());
|
FileUtils.recursiveDelete(platform.getInstalledFolder());
|
||||||
platform.setInstalled(false);
|
platform.setInstalled(false);
|
||||||
platform.setInstalledFolder(null);
|
platform.setInstalledFolder(null);
|
||||||
@ -217,11 +225,14 @@ public class ContributionInstaller {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateIndex() throws Exception {
|
public List<String> updateIndex() throws Exception {
|
||||||
final MultiStepProgress progress = new MultiStepProgress(1);
|
List<String> errors = new LinkedList<String>();
|
||||||
final String statusText = _("Downloading platforms index...");
|
MultiStepProgress progress = new MultiStepProgress(1);
|
||||||
|
String statusText = _("Downloading platforms index...");
|
||||||
|
|
||||||
URL url = new URL(PACKAGE_INDEX_URL);
|
URL url = new URL(PACKAGE_INDEX_URL);
|
||||||
File outputFile = indexer.getIndexFile();
|
File outputFile = indexer.getIndexFile();
|
||||||
@ -232,11 +243,14 @@ public class ContributionInstaller {
|
|||||||
// TODO: Check downloaded index
|
// TODO: Check downloaded index
|
||||||
|
|
||||||
// Replace old index with the updated one
|
// Replace old index with the updated one
|
||||||
if (outputFile.exists())
|
if (outputFile.exists()) {
|
||||||
outputFile.delete();
|
outputFile.delete();
|
||||||
if (!tmpFile.renameTo(outputFile))
|
}
|
||||||
|
if (!tmpFile.renameTo(outputFile)) {
|
||||||
throw new Exception("An error occurred while updating platforms index!");
|
throw new Exception("An error occurred while updating platforms index!");
|
||||||
}
|
}
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
|
||||||
protected void onProgress(Progress progress) {
|
protected void onProgress(Progress progress) {
|
||||||
// Empty
|
// Empty
|
||||||
|
Reference in New Issue
Block a user