From 2a0daf354c7b7519cf19b6b3184cc83758e60dd4 Mon Sep 17 00:00:00 2001 From: prash3r Date: Sun, 2 Oct 2022 18:32:40 +0200 Subject: [PATCH 1/2] moves cbpi_dashboard_*.json to dashboard folder. if the file cbpi_dashboard_1.json doesnt exist in the dashboard folder every cbpi_dashboard_*.json file from the config folder is moved to the dashboard folder. This also removes the empty default cbpi_dashboard_1.json file from the template folder, because the file is not needed for cbpi to function and can be created when editing the dashboard online. --- .../dashboard/cbpi_dashboard_1.json | 3 --- cbpi/config/dashboard/cbpi_dashboard_1.json | 3 --- cbpi/configFolder.py | 11 +++++++++-- 3 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 .devcontainer/cbpi-default-dev-config/dashboard/cbpi_dashboard_1.json delete mode 100644 cbpi/config/dashboard/cbpi_dashboard_1.json diff --git a/.devcontainer/cbpi-default-dev-config/dashboard/cbpi_dashboard_1.json b/.devcontainer/cbpi-default-dev-config/dashboard/cbpi_dashboard_1.json deleted file mode 100644 index 92079a0..0000000 --- a/.devcontainer/cbpi-default-dev-config/dashboard/cbpi_dashboard_1.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "elements": [] -} \ No newline at end of file diff --git a/cbpi/config/dashboard/cbpi_dashboard_1.json b/cbpi/config/dashboard/cbpi_dashboard_1.json deleted file mode 100644 index 92079a0..0000000 --- a/cbpi/config/dashboard/cbpi_dashboard_1.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "elements": [] -} \ No newline at end of file diff --git a/cbpi/configFolder.py b/cbpi/configFolder.py index ef2169b..b35d4a1 100644 --- a/cbpi/configFolder.py +++ b/cbpi/configFolder.py @@ -96,13 +96,13 @@ class ConfigFolder: ['config.json', 'file'], ['craftbeerpi.service', 'file'], ['chromium.desktop', 'file'], - ['dashboard/cbpi_dashboard_1.json', 'file'], - ['dashboard/widgets', 'folder'], ['dashboard', 'folder'], + ['dashboard/widgets', 'folder'], ['fermenterrecipes', 'folder'], [self.logsFolderPath, 'folder'], ['recipes', 'folder'], ['upload', 'folder'] + #['dashboard/cbpi_dashboard_1.json', 'file'] no need to check - can be created with online editor ] for checking in required_config_content: if self.inform_missing_content(self.check_for_file_or_folder(os.path.join(self.configFolderPath, checking[0]), checking[1])): @@ -117,6 +117,13 @@ class ConfigFolder: print("of course you can also place your config files manually") print("***************************************************") return False + + # if cbpi_dashboard_1.json doesnt exist at the new location (configFolderPath/dashboard) + # we move every cbpi_dashboard_n.json file from the old location (configFolderPath) there. + # this could be a config zip file restore from version 4.0.7.a4 or prior. + if not (os.path.isfile(os.path.join(self.configFolderPath, 'dashboard', 'cbpi_dashboard_1.json'))): + for file in glob.glob(os.path.join(self.configFolderPath, 'cbpi_dashboard_*.json')): + shutil.move(file, os.path.join(self.configFolderPath, 'dashboard', os.path.basename(file))) def inform_missing_content(self, whatsmissing : str): if whatsmissing == "": From 7f16a8b9b55e8da58281abb697f0710f505719cf Mon Sep 17 00:00:00 2001 From: prash3r Date: Sun, 2 Oct 2022 19:01:14 +0200 Subject: [PATCH 2/2] not copying empty cbpi_dashboard_1.json anymore. will be created on first dashboard save instead. --- cbpi/configFolder.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cbpi/configFolder.py b/cbpi/configFolder.py index b35d4a1..be01fc0 100644 --- a/cbpi/configFolder.py +++ b/cbpi/configFolder.py @@ -170,11 +170,6 @@ class ConfigFolder: self.copyDefaultFileIfNotExists("craftbeerpi.service") self.copyDefaultFileIfNotExists("chromium.desktop") - if os.path.exists(os.path.join(self.configFolderPath, "dashboard", "cbpi_dashboard_1.json")) is False: - srcfile = os.path.join(os.path.dirname(__file__), "config", "dashboard", "cbpi_dashboard_1.json") - destfile = os.path.join(self.configFolderPath, "dashboard") - shutil.copy(srcfile, destfile) - print("Config Folder created") def create_home_folder_structure(configFolder):