31 lines
980 B
Python
31 lines
980 B
Python
import subprocess
|
|
from subprocess import SubprocessError, TimeoutExpired, CalledProcessError
|
|
import glob
|
|
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
|
|
from hub.imports.results_factory import ResultFactory
|
|
|
|
|
|
class MonthlyEnergyBalanceEngine:
|
|
def __init__(self, city, file_path):
|
|
"""
|
|
MEB class
|
|
:param file_path: insel file path
|
|
"""
|
|
self._city = city
|
|
self._file_path = file_path
|
|
EnergyBuildingsExportsFactory('insel_monthly_energy_balance', self._city, self._file_path).export()
|
|
self._run()
|
|
ResultFactory('insel_meb', self._city, self._file_path).enrich()
|
|
|
|
def _run(self):
|
|
"""
|
|
Calls the software
|
|
"""
|
|
try:
|
|
_insel_files = glob.glob(f'{self._file_path}/*.insel')
|
|
for insel_file in _insel_files:
|
|
subprocess.run(['insel', str(insel_file)], stdout=subprocess.DEVNULL)
|
|
except (SubprocessError, TimeoutExpired, CalledProcessError) as error:
|
|
raise Exception(error)
|
|
|