From 5097c69761460ba1c156815e1061a97e27ec8387 Mon Sep 17 00:00:00 2001 From: Guille Date: Fri, 10 May 2024 19:34:36 +0200 Subject: [PATCH] Correct session helper error and typo --- hub_api/helpers/session_helper.py | 10 ++++++---- hub_api/workflow/energy_plus.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hub_api/helpers/session_helper.py b/hub_api/helpers/session_helper.py index 580da42..371e071 100644 --- a/hub_api/helpers/session_helper.py +++ b/hub_api/helpers/session_helper.py @@ -8,6 +8,7 @@ import shutil import uuid import datetime import time +from copy import deepcopy from pathlib import Path sessions = {} @@ -26,11 +27,12 @@ def expired_sessions_collector(session_timeout_duration): """ while True: if bool(sessions): - for session_uuid in sessions: - _expire = datetime.datetime.strptime(sessions[session_uuid]['expire'], '%Y-%m-%d %H:%M:%S.%f') + _sessions = deepcopy(sessions) + for session_uuid in _sessions: + _expire = datetime.datetime.strptime(_sessions[session_uuid]['expire'], '%Y-%m-%d %H:%M:%S.%f') if _expire < datetime.datetime.now(): - print("session for user: ", sessions[session_uuid]['user'], "expired.") - response_path = (Path(__file__).parent / f'response_files/{session_uuid}').resolve() + print("session for user: ", _sessions[session_uuid]['user'], "expired.") + response_path = (Path(__file__).parent.parent / f'response_files/{session_uuid}').resolve() shutil.rmtree(response_path) del sessions[session_uuid] time.sleep(60 * int(session_timeout_duration)) diff --git a/hub_api/workflow/energy_plus.py b/hub_api/workflow/energy_plus.py index a85f11d..1fca8a9 100644 --- a/hub_api/workflow/energy_plus.py +++ b/hub_api/workflow/energy_plus.py @@ -20,7 +20,7 @@ from hub_api.helpers.session_helper import refresh_session class EnergyPlus(Resource, Config): def __init__(self): super().__init__() - self._extensions = ['.geojson', '.citygml'] + self._extensions = ['.geojson', '.gml'] self._tmp_path = (Path(__file__).parent / 'tmp').resolve() self._response_path = (Path(__file__).parent.parent / 'response_files').resolve() self._city = None @@ -34,7 +34,7 @@ class EnergyPlus(Resource, Config): height_field = request.form.get('height_field') year_of_construction_field = request.form.get('year_of_construction_field') function_field = request.form.get('function_field') - function_dictionary = self._dictionaries[request.form.get('function_dictionary_name')] + function_dictionary = self._dictionaries[request.form.get('function_to_hub')] return GeometryFactory('geojson', path=file_path, height_field=height_field,