Removing Container Name from Paths

This commit is contained in:
Luis Fernando Molina committed 2020-01-28 13:28:30 +01:00
1 parent e88f3eba99
commit 566b0331c0
13 files changed
+44 -51

No files matched your search

+1 -1
View File
@@ -480,7 +480,7 @@
let filePath = filePathRoot + "/Output/" + contextSummary.product + "/" + contextSummary.dataset + "/" + timeFrameLabel + dateForPath;
filePath += '/' + fileName
fileStorage.createTextFile(contextSummary.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
+5 -5
View File
@@ -168,7 +168,7 @@
let fileName = "Execution.History." + bot.startMode + "." + runIndex + ".json";
let filePath = bot.filePathRoot + "/Output/" + sessionPath + "Trading-Process/" + fileName;
fileStorage.getTextFile(bot.dataMine, filePath, onFileReceived);
fileStorage.getTextFile(filePath, onFileReceived);
function onFileReceived(err, text) {
@@ -229,7 +229,7 @@
let dateForPath = date.getUTCFullYear() + '/' + utilities.pad(date.getUTCMonth() + 1, 2) + '/' + utilities.pad(date.getUTCDate(), 2) + '/' + utilities.pad(date.getUTCHours(), 2) + '/' + utilities.pad(date.getUTCMinutes(), 2);
let filePath = bot.filePathRoot + "/Output/" + sessionPath + "Trading-Process/" + dateForPath + fileName;
fileStorage.getTextFile(bot.dataMine, filePath, onFileReceived);
fileStorage.getTextFile(filePath, onFileReceived);
function onFileReceived(err, text) {
@@ -411,7 +411,7 @@
if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write(MODULE_NAME, "[INFO] saveThemAll -> writeExecutionContext -> fileContent = " + fileContent); }
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -472,7 +472,7 @@
let fileContent = JSON.stringify(thisObject.executionHistory);
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -494,7 +494,7 @@
fileName = "Execution.History." + bot.startMode + "." + "Sequence" + ".json";
filePath = bot.filePathRoot + "/Output/" + sessionPath + "Trading-Process/" + fileName;
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onSequenceFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onSequenceFileCreated);
function onSequenceFileCreated(err) {
+2 -2
View File
@@ -108,7 +108,7 @@ exports.newDataSet = function newDataSet(BOT, logger) {
let filePath = filePathRoot + "/Output/" + pFolderPath;
filePath += '/' + pFileName
fileStorage.getTextFile(dataDependencyNode.dataMine, filePath, onFileReceived);
fileStorage.getTextFile(filePath, onFileReceived);
function onFileReceived(err, text) {
@@ -149,7 +149,7 @@ exports.newDataSet = function newDataSet(BOT, logger) {
let filePathRoot = dataDependencyNode.dataMine + "/" + dataDependencyNode.bot + "/" + bot.exchange;
let filePath = filePathRoot + "/Output/" + pFolderPath + '/' + pFileName;
fileStorage.createTextFile(dataDependencyNode.dataMine, filePath, pFileContent, onFileCreated);
fileStorage.createTextFile(filePath, pFileContent, onFileCreated);
function onFileCreated(err) {
+4 -4
View File
@@ -92,22 +92,22 @@ exports.newDebugLog = function newDebugLog() {
let fileToDelete = thisObject.bot.LOGS_TO_DELETE_QUEUE[0]
thisObject.bot.LOGS_TO_DELETE_QUEUE.splice(0, 1)
/* Will delete this file only if it does not contains ERROR inside. */
let fileContent = fileStorage.getTextFile(thisObject.bot.dataMine, fileToDelete, onGetFile, true)
let fileContent = fileStorage.getTextFile(fileToDelete, onGetFile, true)
function onGetFile(err, fileContent) {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
if (fileContent.indexOf("ERROR") < 0) {
/* Logs will only be deleted when they contain no ERROR in them. */
fileStorage.deleteTextFile(thisObject.bot.dataMine, fileToDelete);
fileStorage.deleteTextFile(fileToDelete);
}
} else {
fileStorage.deleteTextFile(thisObject.bot.dataMine, fileToDelete);
fileStorage.deleteTextFile(fileToDelete);
}
}
}
function writeLog() {
fileStorage.createTextFile(thisObject.bot.dataMine, filePath + '/' + fileName, contentToPersist + '\r\n' + "]", onFileCreated);
fileStorage.createTextFile(filePath + '/' + fileName, contentToPersist + '\r\n' + "]", onFileCreated);
function onFileCreated(err) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
console.log("[ERROR] DebugLog -> persist -> onInizialized -> onFileCreated -> err = "+ err.message);
+12 -19
View File
@@ -25,20 +25,18 @@ exports.newFileStorage = function newFileStorage(logger) {
return thisObject
function getTextFile(container, filePath, callBackFunction, noRetry) {
function getTextFile(filePath, callBackFunction, noRetry) {
logger.write(MODULE_NAME, '[INFO] FileStorage -> getTextFile -> Entering Function.')
let fileDoesNotExist = false
container = container.toLowerCase()
/* Choose path for either bots or data */
let fileLocation
if (filePath.indexOf("/bots/") > 0) {
fileLocation = process.env.BOTS_PATH + '/' + container + '/' + filePath
fileLocation = process.env.BOTS_PATH + '/' + filePath
} else {
fileLocation = process.env.STORAGE_PATH + '/' + container + '/' + filePath
fileLocation = process.env.STORAGE_PATH + '/' + filePath
}
try {
@@ -71,7 +69,6 @@ exports.newFileStorage = function newFileStorage(logger) {
}
logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> Error reading file -> err = ' + err.stack)
logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> Error reading file -> container = ' + container)
logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> Error reading file -> filePath = ' + filePath)
logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> Error reading file -> err = ' + err.stack)
setTimeout(retry, RETRY_TIME_IN_MILISECONDS)
@@ -97,7 +94,7 @@ exports.newFileStorage = function newFileStorage(logger) {
if (currentRetryGetTextFile < MAX_RETRY) {
currentRetryGetTextFile++
logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> retry -> Will try to read the file again -> Retry #: ' + currentRetryGetTextFile)
getTextFile(container, filePath, callBackFunction)
getTextFile(filePath, callBackFunction)
} else {
currentRetryGetTextFile = 0
@@ -119,18 +116,16 @@ exports.newFileStorage = function newFileStorage(logger) {
}
}
function createTextFile(container, filePath, fileContent, callBackFunction) {
function createTextFile(filePath, fileContent, callBackFunction) {
logger.write(MODULE_NAME, '[INFO] FileStorage -> createTextFile -> Entering Function.')
container = container.toLowerCase()
/* Choose path for either logs or data */
let fileLocation
if (filePath.indexOf("/Logs/") > 0) {
fileLocation = process.env.LOG_PATH + '/' + container + '/' + filePath
fileLocation = process.env.LOG_PATH + '/' + filePath
} else {
fileLocation = process.env.STORAGE_PATH + '/' + container + '/' + filePath
fileLocation = process.env.STORAGE_PATH + '/' + filePath
}
try {
@@ -198,7 +193,7 @@ exports.newFileStorage = function newFileStorage(logger) {
if (currentRetryWriteTextFile < MAX_RETRY) {
currentRetryWriteTextFile++
logger.write(MODULE_NAME, '[WARN] FileStorage -> createTextFile -> retry -> Will try to write the file again -> Retry #: ' + currentRetryWriteTextFile)
createTextFile(container, filePath, fileContent, callBackFunction)
createTextFile(filePath, fileContent, callBackFunction)
} else {
currentRetryWriteTextFile = 0
logger.write(MODULE_NAME, '[ERROR] FileStorage -> createTextFile -> retry -> Max retries reached writting a file. Giving up.')
@@ -208,18 +203,16 @@ exports.newFileStorage = function newFileStorage(logger) {
}
}
function deleteTextFile(container, filePath, callBackFunction) {
function deleteTextFile(filePath, callBackFunction) {
logger.write(MODULE_NAME, '[INFO] FileStorage -> deleteTextFile -> Entering Function.')
container = container.toLowerCase()
/* Choose path for either logs or data */
let fileLocation
if (filePath.indexOf("/Logs/") > 0) {
fileLocation = process.env.LOG_PATH + '/' + container + '/' + filePath
fileLocation = process.env.LOG_PATH + '/' + filePath
} else {
fileLocation = process.env.STORAGE_PATH + '/' + container + '/' + filePath
fileLocation = process.env.STORAGE_PATH + '/' + filePath
}
try {
@@ -252,7 +245,7 @@ exports.newFileStorage = function newFileStorage(logger) {
if (currentRetryWriteTextFile < MAX_RETRY) {
currentRetryWriteTextFile++
logger.write(MODULE_NAME, '[WARN] FileStorage -> createTextFile -> retry -> Will try to write the file again -> Retry #: ' + currentRetryWriteTextFile)
createTextFile(container, filePath, fileContent, callBackFunction)
createTextFile(filePath, fileContent, callBackFunction)
} else {
currentRetryWriteTextFile = 0
logger.write(MODULE_NAME, '[ERROR] FileStorage -> createTextFile -> retry -> Max retries reached writting a file. Giving up.')
+2 -2
View File
@@ -46,7 +46,7 @@
let filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.codeName
filePath += "/User.Bot.js"
fileStorage.getTextFile(bot.dataMine, filePath, onBotDownloaded);
fileStorage.getTextFile(filePath, onBotDownloaded);
function onBotDownloaded(err, text) {
@@ -64,7 +64,7 @@
filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo;
filePath += "/Commons.js"
fileStorage.getTextFile(bot.dataMine, filePath, onCommonsDownloaded);
fileStorage.getTextFile(filePath, onCommonsDownloaded);
function onCommonsDownloaded(err, text) {
+1 -1
View File
@@ -995,7 +995,7 @@
let fileName = '/Data.Range.' + market.baseAsset + '_' + market.quotedAsset + '.json';
let filePath = bot.filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + productCodeName + "/" + 'Multi-Period-Daily' + fileName;
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
+1 -1
View File
@@ -729,7 +729,7 @@
let fileName = '/Data.Range.' + market.baseAsset + '_' + market.quotedAsset + '.json';
let filePath = bot.filePathRoot + "/Output/" + productCodeName + "/" + bot.process + fileName;
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
+1 -1
View File
@@ -166,7 +166,7 @@
let filePath = global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName + '/bots/' + global.TASK_NODE.bot.code.repo + '/this.bot.config.json';
fileStorage.getTextFile(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName, filePath, onFileReceived);
fileStorage.getTextFile(filePath, onFileReceived);
function onFileReceived(err, text) {
+2 -2
View File
@@ -44,7 +44,7 @@
let filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.codeName
filePath += "/User.Bot.js"
fileStorage.getTextFile(bot.dataMine, filePath, onBotDownloaded);
fileStorage.getTextFile(filePath, onBotDownloaded);
function onBotDownloaded(err, text) {
@@ -69,7 +69,7 @@
filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo;
filePath += "/Commons.js"
fileStorage.getTextFile(bot.dataMine, filePath, onCommonsDownloaded);
fileStorage.getTextFile(filePath, onCommonsDownloaded);
function onCommonsDownloaded(err, text) {
+2 -2
View File
@@ -163,7 +163,7 @@
filePath += '/' + fileName
fileStorage.getTextFile(statusDependencyNode.dataMine, filePath, onFileReceived);
fileStorage.getTextFile(filePath, onFileReceived);
function onFileReceived(err, text) {
@@ -251,7 +251,7 @@
filePath += '/' + fileName
let fileContent = JSON.stringify(thisObject.file);
fileStorage.createTextFile(statusDependencyNode.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
+9 -9
View File
@@ -225,7 +225,7 @@
let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + timeFrameLabel;
filePath += '/' + fileName
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -303,7 +303,7 @@
let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + CONDITIONS_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + timeFrameLabel;
filePath += '/' + fileName
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -373,7 +373,7 @@
let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + STRATEGIES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + timeFrameLabel;
filePath += '/' + fileName
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -446,7 +446,7 @@
let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + TRADES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + timeFrameLabel;
filePath += '/' + fileName
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -572,7 +572,7 @@
let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + timeFrameLabel;
filePath += '/' + fileName
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -679,7 +679,7 @@
let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + timeFrameLabel + "/" + dateForPath;
filePath += '/' + fileName
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -767,7 +767,7 @@
let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + CONDITIONS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + timeFrameLabel + "/" + dateForPath;
filePath += '/' + fileName
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -844,7 +844,7 @@
let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + STRATEGIES_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + timeFrameLabel + "/" + dateForPath;
filePath += '/' + fileName
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
@@ -924,7 +924,7 @@
let filePath = filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + TRADES_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + timeFrameLabel + "/" + dateForPath;
filePath += '/' + fileName
fileStorage.createTextFile(bot.dataMine, filePath, fileContent + '\n', onFileCreated);
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated);
function onFileCreated(err) {
+2 -2
View File
@@ -56,7 +56,7 @@
let filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.codeName
filePath += "/User.Bot.js"
fileStorage.getTextFile(bot.dataMine, filePath, onBotDownloaded);
fileStorage.getTextFile(filePath, onBotDownloaded);
function onBotDownloaded(err, text) {
@@ -75,7 +75,7 @@
filePath = bot.dataMine + "/" + "bots" + "/" + bot.repo;
filePath += "/Commons.js"
fileStorage.getTextFile(bot.dataMine, filePath, onCommonsDownloaded);
fileStorage.getTextFile(filePath, onCommonsDownloaded);
function onCommonsDownloaded(err, text) {