From b156c5dda7d9fc2135fdd6405d9413db5ec8b8be Mon Sep 17 00:00:00 2001 From: Alexis Koralewski Date: Mon, 20 Mar 2023 12:00:35 +0100 Subject: [PATCH] Relocate sequences_pickle folder in data folder --- CHANGELOG | 5 ++++- src/core/pyros_django/routine_manager/functions.py | 16 +++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 70bd92f..96a8c4d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +20-03-2023 (AKo): v0.6.20.0 + - Add night_id to sequences, create folder for night_id + - Change sequences_pickle location (relocate in data folder) + 02-03-2023 (AKo): v0.6.19.0 - Add monitoring_names to plot on website in Pyros Config - Add symbol attributes for Channels & albums in obsconfig @@ -10,7 +14,6 @@ - Rework monitoring views (weather monitoring, history and weather_config) - Add new version of AgentM and AgentDevicePLC - Fix Agent, wasn't executing agent specific commands - - 15-02-2023 (AKo): v0.6.18.0 - Add new version of weather config view diff --git a/src/core/pyros_django/routine_manager/functions.py b/src/core/pyros_django/routine_manager/functions.py index b8b567b..be201fc 100644 --- a/src/core/pyros_django/routine_manager/functions.py +++ b/src/core/pyros_django/routine_manager/functions.py @@ -395,11 +395,13 @@ def create_sequence_pickle(sequence): for plan in album.plans.all(): fullseq_dict["albums"][f"{album.name}"]["plans"].append(model_to_dict(instance=plan)) period = sequence.period - if not os.path.exists("sequences_pickle"): - os.mkdir("./sequences_pickle") - if not os.path.exists(f"sequences_pickle/P{period.id}"): - os.mkdir(f"sequences_pickle/P{period.id}") - if not os.path.exists(f"sequences_pickle/P{period.id}/{sequence.night_id}"): - os.mkdir(f"sequences_pickle/P{period.id}/{sequence.night_id}") - seq_pickle_file_name = f"./sequences_pickle/P{period.id}/{sequence.night_id}/{sequence.id}.p" + root_project_path = os.environ.get("PROJECT_ROOT_PATH") + data_path = root_project_path + "/data/" + if not os.path.exists(data_path + "sequences_pickle"): + os.mkdir(data_path +"sequences_pickle") + if not os.path.exists(data_path + f"sequences_pickle/P{period.id}"): + os.mkdir(data_path + f"sequences_pickle/P{period.id}") + if not os.path.exists(data_path +f"sequences_pickle/P{period.id}/{sequence.night_id}"): + os.mkdir(data_path +f"sequences_pickle/P{period.id}/{sequence.night_id}") + seq_pickle_file_name = data_path +f"./sequences_pickle/P{period.id}/{sequence.night_id}/{sequence.id}.p" pickle.dump(fullseq_dict,open(seq_pickle_file_name,"wb")) \ No newline at end of file -- libgit2 0.21.2