Merge pull request #69 from prash3r/move-dashboard-files

moves cbpi_dashboard_*.json to subfolder dashboard.
This commit is contained in:
Alexander Vollkopf 2022-10-03 11:20:41 +02:00 committed by GitHub
commit 7c87a2b054
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 13 deletions

View file

@ -1,3 +0,0 @@
{
"elements": []
}

View file

@ -1,3 +0,0 @@
{
"elements": []
}

View file

@ -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])):
@ -118,6 +118,13 @@ class ConfigFolder:
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 == "":
return False
@ -163,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):