Finished with Olivia Multi Period Market moved to Alpha

This commit is contained in:
Luis Fernando Molina committed 2018-03-15 12:43:48 +01:00
1 parent 5e0dd485c9
commit ebbe511497
5 files changed
+30 -46

No files matched your search

Binary file not shown.
+20 -4
View File
@@ -164,7 +164,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) {
logger.write("[ERROR] createTextFile -> onFileCreated -> result = " + JSON.stringify(result));
logger.write("[ERROR] createTextFile -> onFileCreated -> response = " + JSON.stringify(response));
if (err.message.indexOf("The server is busy") > 0) {
if (err.message.indexOf("The server is busy") > 0 || err.code === 'ECONNRESET') {
setTimeout(secondTry, 1000);
@@ -236,7 +236,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) {
if (err) {
if (err.message.indexOf("The server is busy") > 0) {
if (err.message.indexOf("The server is busy") > 0 || err.code === 'ECONNRESET') {
setTimeout(secondTry, 1000);
@@ -259,7 +259,23 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) {
}
}
if (err.code = "ParentNotFound") {
if (err.code === "ResourceNotFound") {
/* This is how Azure tell us the file does not exist. */
let customErr = {
result: global.CUSTOM_FAIL_RESPONSE.result,
message: "File does not exist."
};
logger.write("[ERROR] getTextFile -> onFileReceived -> Custom Response -> message = " + customErr.message);
callBackFunction(customErr);
return;
}
if (err.code === "ParentNotFound") {
/* This is how Azure tell us the folder where the file was supposed to be does not exist. We map this to our own response. */
@@ -274,7 +290,7 @@ exports.newAzureFileStorage = function newAzureFileStorage(BOT) {
return;
}
logger.write("[ERROR] getTextFile -> onFileReceived -> Dont know what to do here. Cancelling operation. ");
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
+1 -37
View File
@@ -63,47 +63,11 @@
/* We will prepare first the infraestructure needed for the bot to run. There are 3 modules we need to sucessfullly initialize first. */
let statusReport;
let userBot;
let nextWaitTime;
initializeStatusReport();
function initializeStatusReport() {
if (FULL_LOG === true) { logger.write("[INFO] run -> loop -> initializeStatusReport -> Entering function."); }
statusReport = STATUS_REPORT.newStatusReport(bot, DEBUG_MODULE, FILE_STORAGE, UTILITIES);
statusReport.initialize(bot, onInizialized);
function onInizialized(err) {
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeStatusReport -> onInizialized > Execution finished well. :-)");
initializeUserBot();
return;
}
case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time.
logger.write("[ERROR] run -> loop -> initializeStatusReport -> onInizialized > Retry Later. Requesting Execution Retry.");
nextWaitTime = 'Retry';
loopControl(nextWaitTime);
return;
}
case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle.
logger.write("[ERROR] run -> loop -> initializeStatusReport -> onInizialized > Operation Failed. Aborting the process.");
callBackFunction(err);
return;
}
case global.CUSTOM_FAIL_RESPONSE.result: {
logger.write("[INFO] run -> loop -> initializeStatusReport -> onInizialized > Execution finished with some expected issue.");
initializeUserBot();
return;
}
}
}
}
initializeUserBot();
function initializeUserBot() {
+4
View File
@@ -131,6 +131,10 @@ global.dailyFilePeriods =
global.dailyFilePeriods = JSON.parse(global.dailyFilePeriods);
/* File Path Root */
global.FILE_PATH_ROOT = botConfig.devTeam + "/" + botConfig.codeName + "." + botConfig.version.major + "." + botConfig.version.minor + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor + "/" + global.EXCHANGE_NAME + "/" + botConfig.dataSetVersion;
/* Some LAGACY code starts here. Pending for clean up. */
const INTERVAL_EXECUTOR_MODULE = require('./Interval Executor');
+5 -5
View File
@@ -117,7 +117,7 @@
if (FULL_LOG === true) { logger.write("[INFO] initialize -> getFile -> Entering function."); }
let fileName = "Status.Report.json"
let filePath = ownerBot.devTeam + "/" + ownerBot.codeName + "." + ownerBot.version.major + "." + ownerBot.version.minor + "/" + ownerBot.dataSetVersion + "/Processes/" + ownerBot.process + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor;
let filePath = global.FILE_PATH_ROOT + "/Reports/" + bot.process;
if (FULL_LOG === true) { logger.write("[INFO] initialize -> getFile -> fileName = " + fileName); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> getFile -> filePath = " + filePath); }
@@ -131,7 +131,7 @@
/* In this case we can assume that this is the first execution ever of this bot.*/
thisObject.statusReport = JSON.parse('{}');
thisObject.file = JSON.parse('{}');
let customErr = {
result: global.CUSTOM_FAIL_RESPONSE.result,
@@ -154,7 +154,7 @@
try {
thisObject.statusReport = JSON.parse(text);
thisObject.file = JSON.parse(text);
callBack(global.DEFAULT_OK_RESPONSE);
} catch (err) {
@@ -202,7 +202,7 @@
}
let fileName = "Status.Report.json"
let filePath = bot.devTeam + "/" + bot.codeName + "." + bot.version.major + "." + bot.version.minor + "/" + bot.dataSetVersion + "/Processes/" + bot.process + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor;
let filePath = global.FILE_PATH_ROOT + "/Reports/" + bot.process;
if (FULL_LOG === true) { logger.write("[INFO] save -> fileName = " + fileName); }
if (FULL_LOG === true) { logger.write("[INFO] save -> filePath = " + filePath); }
@@ -221,7 +221,7 @@
return;
}
let fileContent = JSON.stringify(thisObject.statusReport);
let fileContent = JSON.stringify(thisObject.file);
cloudStorage.createTextFile(filePath, fileName, fileContent + '\n', onFileCreated);