From f9c9dc5aac031af23a279a9aa92daa5924dd1b98 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 5 Mar 2018 03:51:08 +0100 Subject: [PATCH] Configuration Changes --- .vs/AAWebPlatform/v15/.suo | Bin 70656 -> 71680 bytes server.js | 105 ++++++++++++++++++++++++++++++++++++- 2 files changed, 103 insertions(+), 2 deletions(-) diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index baef56c4ed9fe7371df2a561a518770b89ac9cb1..bb012702fc092b49ee10502a736945bd474f9100 100644 GIT binary patch delta 1714 zcmd6me{54#6vy9vz1?2h*Y2@7yLEPb?S^zt%bXh<=%iaKEW^Z2q4Gx+_7et^&31KC z!8K?Um`3O!jOZW2Q+_0a!1`2z;g3FIkm$xxiNW~K@DF3=KPJ*8{$TaoGEAL`i5e4c z`sqFQoO{0K+;`uLouIKZbYB$=9556~9B1Y@PKV5;(`lSIf)tIn{X$3%IC+QVOz{(S z_rCW9S;K-Y5apv}38eU!NIq=WwU~*BZU=(tX=rnnlP!?aEz#T1RSZsAV0aL%Jfs8~ zXj#Qg+?Ix0Tpg-L3OZ7TA_$Z-8@#;}v(|9oUc( zgr(VWE=3%Oj5rY&Ql|DAhe%u;BzHqZ943n)b;n~OdtU59nRezv${}L@{_l!P&4MXQ zL>-hU&(Babn%_c1Ce7ZP+a=&eK`g6>VN$L}3P*&5SLRi@dYV9OYo40t>J>8zo>z47 znsT}q1ys4~8i}v+fp7Iw>fy~BNqncIN_`Th)lZuf%RahQ>z+T-6u4{7JZ_`id5OBW+=T(CENb^S=-r{%5}LHe*N zk&F?;41Qh(sKLV?Z76YmmKcBUjr+g!b(knHq6OZGUDCmI&1z~5^>;-&2Yv0KE|}AH z!L{&WczeUD|jy_?F0ScU}NKx-5src?Sno2p=W|wJK^Z$s>1c`Wy%a&@>R5J z(DuV#ZMSljhtpd0UmpO-TX&9HOhg3x8cD7G_Ok9j>v$$dxk{DqjPT8ue%1fOd7U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`A7j99xBa8>s321@S)tmHE_X diff --git a/server.js b/server.js index cde7f7808..77e6e4d00 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,7 @@ if (CONSOLE_LOG === true) { } -const DEBUG_MODE = true; // This forces the server to read Plotters from the local drive. +const DEBUG_MODE = false; // This forces the server to read Plotters from the local drive. if (CONSOLE_LOG === true && DEBUG_MODE === true) { @@ -141,7 +141,7 @@ function initialize() { if (requestsSent === responsesReceived) { - startHtttpServer(); + readBotsConfig(); } } @@ -171,6 +171,107 @@ function initialize() { let configObj = JSON.parse(pData); competition.configObj = configObj; + if (requestsSent === responsesReceived) { + + readBotsConfig(); + + } + + } + catch (err) { + console.log("readCompetitionsConfig Error = " + err); + } + } + } + } + } + } + + function readBotsConfig() { + + /* + + Each bot has its configuration at its own repo since each team must be able to change it at will. + So what we do here is to use the master config at the AAPlatform repo that we already have on + memory and inject into it the config of each bot. + + */ + + let requestsSent = 0; + let responsesReceived = 0; + + for (let i = 0; i < ecosystemObject.devTeams.length; i++) { + + let devTeam = ecosystemObject.devTeams[i]; + + for (let j = 0; j < devTeam.bots.length; j++) { + + let bot = devTeam.bots[j]; + + requestsSent++; + + if (DEBUG_MODE === true) { + + let fs = require('fs'); + try { + let fileName = '../Bots/' + devTeam.codeName + '/' + bot.repo + '/' + bot.configFile; + fs.readFile(fileName, onFileRead); + + function onFileRead(err, pData) { + + try { + responsesReceived++; + + pData = pData.toString(); + pData = pData.trim(); // remove first byte with some encoding. + + let configObj = JSON.parse(pData); + + /* Since we are going to replace the full bot object and we dont want to lose these two properties, we do this: */ + + configObj.repo = bot.repo; + configObj.configFile = bot.configFile; + + devTeam.bots[j] = configObj; + + if (requestsSent === responsesReceived) { + + startHtttpServer(); + + } + } + catch (err) { + console.log("File Not Found: " + fileName + " or Error = " + err); + } + + } + } + catch (err) { + console.log(err); + } + + } else { + + getGithubData(devTeam.codeName, bot.repo, bot.configFile, onDataArrived) + + function onDataArrived(pData) { + + try { + + responsesReceived++; + + pData = pData.toString(); + pData = pData.trim(); // remove first byte with some encoding. + + let configObj = JSON.parse(pData); + + /* Since we are going to replace the full bot object and we dont want to lose these two properties, we do this: */ + + configObj.repo = bot.repo; + configObj.configFile = bot.configFile; + + devTeam.bots[j] = configObj; + if (requestsSent === responsesReceived) { startHtttpServer();