Reading Bot Files from members Area

This commit is contained in:
Luis Fernando Molina committed 2018-06-02 12:36:51 +02:00
1 parent 3bbafb05d5
commit e582c5f0ab
6 files changed
+112 -46

No files matched your search

+4 -36
View File
@@ -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) {
+33 -3
View File
@@ -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) {
+33 -3
View File
@@ -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) {
+7
View File
@@ -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: {
+1
View File
@@ -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);
+34 -4
View File
@@ -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."); }