diff --git a/main.js b/main.js index b051c87..5eb9629 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,6 @@ const Factory = require('./factory.js') const { app, BrowserWindow, ipcMain, ipcRenderer } = require('electron') +const { tmpdir } = require('node:os') const path = require('node:path') const createWindow = () => { @@ -12,11 +13,12 @@ const createWindow = () => { }) win.loadFile('index.html') } +tmp = tmpdir() app.disableHardwareAcceleration() app.whenReady().then(() => { ipcMain.handle('run', (_, param) => { Factory.get(param.workflow) - Factory.workflow.run(param.application, param, './tmp/') + Factory.workflow.run(param.application, param, tmp) }) createWindow() app.on('window-all-closed', () => { diff --git a/tmp/.gitignore b/tmp/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/workflows/energy_plus/module/module.js b/workflows/energy_plus/module/module.js index 1e18c01..1249bbf 100644 --- a/workflows/energy_plus/module/module.js +++ b/workflows/energy_plus/module/module.js @@ -49,11 +49,11 @@ exports.run = async (application, param, tmp_path) => { var blob = await response.blob() const buffer = Buffer.from(await blob.arrayBuffer()) require("fs").writeFile( - `${tmp_path}energyplus_results.zip`, + `${tmp_path}/energyplus_results.zip`, buffer, (err) => { console.log(err ? err : 'energy+ zip saved'); } ) - BrowserWindow.fromId(1).webContents.send('task-completed', 'Energy plus results') + BrowserWindow.fromId(1).webContents.send('task-completed', `Energy plus results`) return } else if (response.status == 400) { diff --git a/workflows/meb/module/module.js b/workflows/meb/module/module.js index 942d3c7..a5dec0d 100644 --- a/workflows/meb/module/module.js +++ b/workflows/meb/module/module.js @@ -85,11 +85,11 @@ exports.run = async (application, param, tmp_path) => { meb_lines.push(meb) } require("fs").writeFile( - `${tmp_path}meb.csv`, + `${tmp_path}/meb.csv`, `${meb_header}\n${meb_lines.join('\n')}`, function (err) { console.log(err ? err : 'meb saved') } ) - BrowserWindow.fromId(1).webContents.send('task-completed', 'meb') + BrowserWindow.fromId(1).webContents.send('task-completed', `meb`) return } else if (response.status == 400) { diff --git a/workflows/retrofit/module/module.js b/workflows/retrofit/module/module.js index 81bd9f1..be8e0b4 100644 --- a/workflows/retrofit/module/module.js +++ b/workflows/retrofit/module/module.js @@ -172,21 +172,21 @@ exports.run = async (application, param, tmp_path) => { }) } require("fs").writeFile( - `${tmp_path}meb.csv`, + `${tmp_path}/meb.csv`, `${meb_header}\n${meb_lines.join('\n')}`, function (err) { console.log(err ? err : 'meb saved') } ) require("fs").writeFile( - `${tmp_path}cost.csv`, + `${tmp_path}/cost.csv`, `${costs_header}\n${cost_lines.join('\n')}`, function (err) { console.log(err ? err : 'cost saved') } ) require("fs").writeFile( - `${tmp_path}operational_co2.csv`, + `${tmp_path}/operational_co2.csv`, `${operational_co2_header}\n${operational_co2_lines.join('\n')}`, function (err) { console.log(err ? err : 'operational_co2 saved') } ) - BrowserWindow.fromId(1).webContents.send('task-completed', 'meb
costs
operational_co2') + BrowserWindow.fromId(1).webContents.send('task-completed', `meb
costs
operational_co2`) } else { console.log('unautorized retrofit')