Uses tmp folder from OS instead local one
This commit is contained in:
parent
ea806dd6dd
commit
d438b4ec0c
4
main.js
4
main.js
@ -1,5 +1,6 @@
|
|||||||
const Factory = require('./factory.js')
|
const Factory = require('./factory.js')
|
||||||
const { app, BrowserWindow, ipcMain, ipcRenderer } = require('electron')
|
const { app, BrowserWindow, ipcMain, ipcRenderer } = require('electron')
|
||||||
|
const { tmpdir } = require('node:os')
|
||||||
const path = require('node:path')
|
const path = require('node:path')
|
||||||
|
|
||||||
const createWindow = () => {
|
const createWindow = () => {
|
||||||
@ -12,11 +13,12 @@ const createWindow = () => {
|
|||||||
})
|
})
|
||||||
win.loadFile('index.html')
|
win.loadFile('index.html')
|
||||||
}
|
}
|
||||||
|
tmp = tmpdir()
|
||||||
app.disableHardwareAcceleration()
|
app.disableHardwareAcceleration()
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
ipcMain.handle('run', (_, param) => {
|
ipcMain.handle('run', (_, param) => {
|
||||||
Factory.get(param.workflow)
|
Factory.get(param.workflow)
|
||||||
Factory.workflow.run(param.application, param, './tmp/')
|
Factory.workflow.run(param.application, param, tmp)
|
||||||
})
|
})
|
||||||
createWindow()
|
createWindow()
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
|
2
tmp/.gitignore
vendored
2
tmp/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
@ -49,11 +49,11 @@ exports.run = async (application, param, tmp_path) => {
|
|||||||
var blob = await response.blob()
|
var blob = await response.blob()
|
||||||
const buffer = Buffer.from(await blob.arrayBuffer())
|
const buffer = Buffer.from(await blob.arrayBuffer())
|
||||||
require("fs").writeFile(
|
require("fs").writeFile(
|
||||||
`${tmp_path}energyplus_results.zip`,
|
`${tmp_path}/energyplus_results.zip`,
|
||||||
buffer,
|
buffer,
|
||||||
(err) => { console.log(err ? err : 'energy+ zip saved'); }
|
(err) => { console.log(err ? err : 'energy+ zip saved'); }
|
||||||
)
|
)
|
||||||
BrowserWindow.fromId(1).webContents.send('task-completed', '<a href="../../tmp/energyplus_results.zip">Energy plus results</a>')
|
BrowserWindow.fromId(1).webContents.send('task-completed', `<a href="${tmp_path}/energyplus_results.zip">Energy plus results</a>`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else if (response.status == 400) {
|
else if (response.status == 400) {
|
||||||
|
@ -85,11 +85,11 @@ exports.run = async (application, param, tmp_path) => {
|
|||||||
meb_lines.push(meb)
|
meb_lines.push(meb)
|
||||||
}
|
}
|
||||||
require("fs").writeFile(
|
require("fs").writeFile(
|
||||||
`${tmp_path}meb.csv`,
|
`${tmp_path}/meb.csv`,
|
||||||
`${meb_header}\n${meb_lines.join('\n')}`,
|
`${meb_header}\n${meb_lines.join('\n')}`,
|
||||||
function (err) { console.log(err ? err : 'meb saved') }
|
function (err) { console.log(err ? err : 'meb saved') }
|
||||||
)
|
)
|
||||||
BrowserWindow.fromId(1).webContents.send('task-completed', '<a href="../../tmp/meb.csv">meb</a>')
|
BrowserWindow.fromId(1).webContents.send('task-completed', `<a href="${tmp_path}/meb.csv">meb</a>`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else if (response.status == 400) {
|
else if (response.status == 400) {
|
||||||
|
@ -172,21 +172,21 @@ exports.run = async (application, param, tmp_path) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
require("fs").writeFile(
|
require("fs").writeFile(
|
||||||
`${tmp_path}meb.csv`,
|
`${tmp_path}/meb.csv`,
|
||||||
`${meb_header}\n${meb_lines.join('\n')}`,
|
`${meb_header}\n${meb_lines.join('\n')}`,
|
||||||
function (err) { console.log(err ? err : 'meb saved') }
|
function (err) { console.log(err ? err : 'meb saved') }
|
||||||
)
|
)
|
||||||
require("fs").writeFile(
|
require("fs").writeFile(
|
||||||
`${tmp_path}cost.csv`,
|
`${tmp_path}/cost.csv`,
|
||||||
`${costs_header}\n${cost_lines.join('\n')}`,
|
`${costs_header}\n${cost_lines.join('\n')}`,
|
||||||
function (err) { console.log(err ? err : 'cost saved') }
|
function (err) { console.log(err ? err : 'cost saved') }
|
||||||
)
|
)
|
||||||
require("fs").writeFile(
|
require("fs").writeFile(
|
||||||
`${tmp_path}operational_co2.csv`,
|
`${tmp_path}/operational_co2.csv`,
|
||||||
`${operational_co2_header}\n${operational_co2_lines.join('\n')}`,
|
`${operational_co2_header}\n${operational_co2_lines.join('\n')}`,
|
||||||
function (err) { console.log(err ? err : 'operational_co2 saved') }
|
function (err) { console.log(err ? err : 'operational_co2 saved') }
|
||||||
)
|
)
|
||||||
BrowserWindow.fromId(1).webContents.send('task-completed', '<a href="../../tmp/meb.csv">meb</a><br /><a href="../../tmp/cost.csv">costs</a><br /><a href="../../tmp/operational_co2.csv">operational_co2</a>')
|
BrowserWindow.fromId(1).webContents.send('task-completed', `<a href="${tmp_path}/meb.csv">meb</a><br /><a href="${tmp_path}/cost.csv">costs</a><br /><a href="${tmp_path}/operational_co2.csv">operational_co2</a>`)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log('unautorized retrofit')
|
console.log('unautorized retrofit')
|
||||||
|
Loading…
Reference in New Issue
Block a user