diff --git a/CloudRequire.js b/CloudRequire.js index 20c4e72a0..ddf3d5c85 100644 --- a/CloudRequire.js +++ b/CloudRequire.js @@ -19,31 +19,15 @@ return thisObject; - function downloadBot(pCloudStorage, pProcessConfig, callBackFunction) { + function downloadBot(pCloudStorage, pFilePath, callBackFunction) { try { if (FULL_LOG === true) { logger.write("[INFO] downloadBot -> Entering function."); } - let filePath; - - switch (global.CURRENT_EXECUTION_AT) { - case "Cloud": { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. - break; - } - case "Browser": { - filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser. - break; - } - default: { - console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' "); - } - } - let fileName = "User.Bot.js"; - pCloudStorage.getTextFile(filePath, fileName, onFileReceived); + pCloudStorage.getTextFile(pFilePath, fileName, onFileReceived); function onFileReceived(err, text) { @@ -74,31 +58,15 @@ } } - function downloadCommons(pCloudStorage, callBackFunction) { + function downloadCommons(pCloudStorage, pFilePath, callBackFunction) { try { if (FULL_LOG === true) { logger.write("[INFO] downloadCommons -> Entering function."); } - let filePath; - - switch (global.CURRENT_EXECUTION_AT) { - case "Cloud": { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; // DevTeams bots only are run at the cloud. - break; - } - case "Browser": { - filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo; // DevTeam Members bots only are run at the browser. - break; - } - default: { - console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' "); - } - } - let fileName = "Commons.js"; - pCloudStorage.getTextFile(filePath, fileName, onFileReceived); + pCloudStorage.getTextFile(pFilePath, fileName, onFileReceived); function onFileReceived(err, text) { diff --git a/ExtractionBotProcessMainLoop.js b/ExtractionBotProcessMainLoop.js index f811f1c3e..fe3a80389 100644 --- a/ExtractionBotProcessMainLoop.js +++ b/ExtractionBotProcessMainLoop.js @@ -48,12 +48,28 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { - /* We needed the cloudStorage initialized for both requesting the bot source code and, later requesting the AACloud condig at ShallWeStop function. */ + /* We needed the cloudStorage initialized for both requesting the bot source code and, later requesting the AACloud config at the ShallWeStop function. */ + + let filePath; + + switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. + case "Cloud": { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + break; + } + case "Browser": { + filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser. + break; + } + default: { + console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' "); + } + } const CLOUD_REQUIRE = require(ROOT_DIR + 'CloudRequire'); let cloudRequire = CLOUD_REQUIRE.newCloudRequire(bot, DEBUG_MODULE); - cloudRequire.downloadBot(cloudStorage, pProcessConfig, onBotDownloaded); + cloudRequire.downloadBot(cloudStorage, filePath, onBotDownloaded); function onBotDownloaded(err, pMODULE) { @@ -67,7 +83,21 @@ USER_BOT_MODULE = pMODULE; - cloudRequire.downloadCommons(cloudStorage, onCommonsDownloaded); + switch (global.CURRENT_EXECUTION_AT) { + case "Cloud": { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; + break; + } + case "Browser": { + filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo; + break; + } + default: { + console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' "); + } + } + + cloudRequire.downloadCommons(cloudStorage, filePath, onCommonsDownloaded); function onCommonsDownloaded(err, pMODULE) { diff --git a/IndicatorBotProcessMainLoop.js b/IndicatorBotProcessMainLoop.js index d75b53f94..0f8e6ac57 100644 --- a/IndicatorBotProcessMainLoop.js +++ b/IndicatorBotProcessMainLoop.js @@ -48,12 +48,28 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { - /* We needed the cloudStorage initialized for both requesting the bot source code and, later requesting the AACloud condig at ShallWeStop function. */ + /* We needed the cloudStorage initialized for both requesting the bot source code and, later requesting the AACloud config at the ShallWeStop function. */ + + let filePath; + + switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. + case "Cloud": { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + break; + } + case "Browser": { + filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser. + break; + } + default: { + console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' "); + } + } const CLOUD_REQUIRE = require(ROOT_DIR + 'CloudRequire'); let cloudRequire = CLOUD_REQUIRE.newCloudRequire(bot, DEBUG_MODULE); - cloudRequire.downloadBot(cloudStorage, pProcessConfig, onBotDownloaded); + cloudRequire.downloadBot(cloudStorage, filePath, onBotDownloaded); function onBotDownloaded(err, pMODULE) { @@ -67,7 +83,21 @@ USER_BOT_MODULE = pMODULE; - cloudRequire.downloadCommons(cloudStorage, onCommonsDownloaded); + switch (global.CURRENT_EXECUTION_AT) { + case "Cloud": { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; + break; + } + case "Browser": { + filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo; + break; + } + default: { + console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' "); + } + } + + cloudRequire.downloadCommons(cloudStorage, filePath, onCommonsDownloaded); function onCommonsDownloaded(err, pMODULE) { diff --git a/Root.js b/Root.js index c1c7627ea..a4773d5b3 100644 --- a/Root.js +++ b/Root.js @@ -256,10 +256,17 @@ exports.newRoot = function newRoot() { switch (global.CURRENT_EXECUTION_AT) { case "Cloud": { filePath = global.DEV_TEAM + "/" + "bots" + "/" + listItem.repo; // DevTeams bots only are run at the cloud. + + console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> Getting Bot Config from the devTeams's Bot. "); + console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> filePath = " + filePath); break; } case "Browser": { filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + listItem.repo; // DevTeam Members bots only are run at the browser. + + console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> Getting Bot Config from the endUser's Bot. "); + console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> global.USER_LOGGED_IN = " + global.USER_LOGGED_IN); + console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> filePath = " + filePath); break; } default: { diff --git a/Run.js b/Run.js index db51a366b..007885fa7 100644 --- a/Run.js +++ b/Run.js @@ -4,6 +4,7 @@ global.CURRENT_EXECUTION_AT = "Cloud"; global.SHALL_BOT_STOP = false; global.USER_LOGGED_IN = "ciencias"; global.DEV_TEAM = "AAMasters"; +global.AT_BREAKPOINT = false; // This is used only when running at the browser. process.on('uncaughtException', function (err) { console.log('[INFO] Run -> uncaughtException -> err.message = ' + err.message); diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index 2bfc4f37e..6cf0ebe33 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -49,12 +49,28 @@ if (err.result === global.DEFAULT_OK_RESPONSE.result) { - /* We needed the cloudStorage initialized for both requesting the bot source code and, later requesting the AACloud condig at ShallWeStop function. */ + /* We needed the cloudStorage initialized for both requesting the bot source code and, later requesting the AACloud config at the ShallWeStop function. */ + + let filePath; + + switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. + case "Cloud": { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + break; + } + case "Browser": { + filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser. + break; + } + default: { + console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' "); + } + } const CLOUD_REQUIRE = require(ROOT_DIR + 'CloudRequire'); let cloudRequire = CLOUD_REQUIRE.newCloudRequire(bot, DEBUG_MODULE); - cloudRequire.downloadBot(cloudStorage, pProcessConfig, onBotDownloaded); + cloudRequire.downloadBot(cloudStorage, filePath, onBotDownloaded); function onBotDownloaded(err, pMODULE) { @@ -68,7 +84,21 @@ USER_BOT_MODULE = pMODULE; - cloudRequire.downloadCommons(cloudStorage, onCommonsDownloaded); + switch (global.CURRENT_EXECUTION_AT) { + case "Cloud": { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo; + break; + } + case "Browser": { + filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + bot.repo; + break; + } + default: { + console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser' "); + } + } + + cloudRequire.downloadCommons(cloudStorage, filePath, onCommonsDownloaded); function onCommonsDownloaded(err, pMODULE) { @@ -288,7 +318,7 @@ if (FULL_LOG === true) { logger.write("[INFO] run -> loop -> bot.processDatetime = " + bot.processDatetime); } - if (AT_BREAKPOINT === true) { + if (global.AT_BREAKPOINT === true) { if (FULL_LOG === true) { logger.write("[INFO] run -> loop -> Plot Breakpoint Hit."); }