show fail on Go Home if interface not present

This commit is contained in:
Stephen Birarda 2016-01-04 18:49:13 -08:00
parent f7ced05876
commit a103839396
2 changed files with 62 additions and 47 deletions

View file

@ -56,12 +56,23 @@ if (argv.localDebugBuilds || argv.localReleaseBuilds) {
acPath = pathFinder.discoveredPath("assignment-client", argv.localReleaseBuilds);
}
function binaryMissingMessage(binaryName) {
var message = "The " + binaryName + " executable was not found.\n";
message += "It is required for the Server Console to run.\n\n";
function binaryMissingMessage(displayName, executableName, required) {
var message = "The " + displayName + " executable was not found.\n";
if (required) {
message += "It is required for the Server Console to run.\n\n";
} else {
message += "\n";
}
if (debug) {
message += "Please ensure there is a compiled " + binaryName + " in a folder named build in this checkout.";
message += "Please ensure there is a compiled " + displayName + " in a folder named build in this checkout.\n\n";
message += "It was expected to be found at one of the following paths:\n";
var paths = pathFinder.searchPaths(executableName, argv.localReleaseBuilds);
for (var i = 0; i < paths.length; i++) {
message += paths[i] + "\n";
}
} else {
message += "It is expected to be found beside this executable.\n"
message += "You may need to re-install the Server Console.";
@ -73,12 +84,12 @@ function binaryMissingMessage(binaryName) {
// if at this point any of the paths are null, we're missing something we wanted to find
if (!dsPath) {
dialog.showErrorBox("Domain Server Not Found", binaryMissingMessage("domain-server"));
dialog.showErrorBox("Domain Server Not Found", binaryMissingMessage("domain-server", "domain-server", true));
app.quit();
}
if (!acPath) {
dialog.showErrorBox("Assignment Client Not Found", binaryMissingMessage("assignment-client"))
dialog.showErrorBox("Assignment Client Not Found", binaryMissingMessage("assignment-client", "assignment-client", true))
app.quit();
}
@ -115,11 +126,20 @@ const RESTART_INDEX = 3;
const STOP_INDEX = 4;
const SETTINGS_INDEX = 5;
function goHomeClicked() {
if (interfacePath) {
startInterface('hifi://localhost');
} else {
// show an error to say that we can't go home without an interface instance
dialog.showErrorBox("Client Not Found", binaryMissingMessage("High Fidelity Client", "Interface", false));
}
}
function buildMenuArray(serverState) {
var menuArray = [
{
label: 'Go Home',
click: function() { startInterface('hifi://localhost'); },
click: goHomeClicked,
enabled: false
},
{
@ -220,7 +240,7 @@ app.on('ready', function() {
updateTrayMenu(ProcessGroupStates.STOPPED);
if (interfacePath && dsPath && acPath) {
if (dsPath && acPath) {
homeServer = new ProcessGroup('home', [
new Process('domain-server', dsPath),
new Process('ac-monitor', acPath, ['-n6', '--log-directory', logPath])

View file

@ -1,54 +1,49 @@
var fs = require('fs');
exports.discoveredPath = function (name, preferRelease) {
var path = "../build/" + name + "/";
function binaryFromPath(name, path) {
function platformExtension(name) {
if (name == "Interface") {
if (process.platform == "darwin") {
return ".app/Contents/MacOS/" + name
} else if (process.platform == "win32") {
return ".exe"
} else {
return ""
}
exports.searchPaths = function(name, preferRelease) {
function platformExtension(name) {
if (name == "Interface") {
if (process.platform == "darwin") {
return ".app/Contents/MacOS/" + name
} else if (process.platform == "win32") {
return ".exe"
} else {
return process.platform == "win32" ? ".exe" : ""
return ""
}
} else {
return process.platform == "win32" ? ".exe" : ""
}
}
var extension = platformExtension(name);
var fullPath = path + name + extension;
var extension = platformExtension(name);
var basePath = "../build/" + name + "/";
try {
var stats = fs.lstatSync(fullPath);
return [
basePath + name + extension,
basePath + (preferRelease ? "Release/" : "Debug/") + name + extension
];
}
if (stats.isFile() || (stats.isDirectory() && extension == ".app")) {
console.log("Found " + name + " at " + fullPath);
return fullPath;
exports.discoveredPath = function (name, preferRelease) {
function binaryFromPaths(name, paths) {
for (var i = 0; i < paths.length; i++) {
var path = paths[i];
try {
var stats = fs.lstatSync(path);
if (stats.isFile() || (stats.isDirectory() && extension == ".app")) {
console.log("Found " + name + " at " + path);
return path;
}
} catch (e) {
console.warn("Executable with name " + name + " not found at path " + path);
}
} catch (e) {
console.warn("Executable with name " + name + " not found at path " + fullPath);
}
return null;
}
// does the executable exist at this path already?
// if so assume we're on a platform that doesn't have Debug/Release
// folders and just use the discovered executable
var matchingBinary = binaryFromPath(name, path);
if (matchingBinary == null) {
if (preferRelease) {
// check if we can find the executable in a Release folder below this path
matchingBinary = binaryFromPath(name, path + "Release/");
} else {
// check if we can find the executable in a Debug folder below this path
matchingBinary = binaryFromPath(name, path + "Debug/");
}
}
return matchingBinary;
// attempt to find a binary at the usual paths, return null if it doesn't exist
return binaryFromPaths(name, this.searchPaths(name, preferRelease));
}