copy craftbeerpi.template file to config folder if not existing after upgrade

This commit is contained in:
avollkopf 2023-10-18 19:43:26 +02:00
parent 7594395b4b
commit bead2b30ae
4 changed files with 11 additions and 6 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.2.0.a3" __version__ = "4.2.0.a4"
__codename__ = "Indian Summer" __codename__ = "Indian Summer"

View file

@ -106,7 +106,7 @@ class ConfigFolder:
] ]
for checking in required_config_content: 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])): if self.inform_missing_content(self.check_for_file_or_folder(os.path.join(self.configFolderPath, checking[0]), checking[1])):
# since there is no complete config we now check if the config folde rmay be completely empty to show hints: # since there is no complete config we now check if the config folder may be completely empty to show hints:
if len(os.listdir(os.path.join(self.configFolderPath))) == 0 : if len(os.listdir(os.path.join(self.configFolderPath))) == 0 :
print("***************************************************") print("***************************************************")
print(f"the config folder '{self.configFolderPath}' seems to be completely empty") print(f"the config folder '{self.configFolderPath}' seems to be completely empty")
@ -118,7 +118,7 @@ class ConfigFolder:
print("***************************************************") print("***************************************************")
return False return False
# if cbpi_dashboard_1.json doesnt exist at the new location (configFolderPath/dashboard) # if cbpi_dashboard_1.json does'nt exist at the new location (configFolderPath/dashboard)
# we move every cbpi_dashboard_n.json file from the old location (configFolderPath) there. # 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. # this could be a config zip file restore from version 4.0.7.a4 or prior.
dashboard_1_path = os.path.join(self.configFolderPath, 'dashboard', 'cbpi_dashboard_1.json') dashboard_1_path = os.path.join(self.configFolderPath, 'dashboard', 'cbpi_dashboard_1.json')
@ -132,7 +132,7 @@ class ConfigFolder:
try: try:
with open(dashboard_1_path, 'r') as f: with open(dashboard_1_path, 'r') as f:
data = json.load(f) data = json.load(f)
if (len(data['elements']) == 0): # there may exist some pathes but pathes without elements in dashboard is not very likely if (len(data['elements']) == 0): # there may exist some paths but paths without elements in dashboard is not very likely
return True return True
else: else:
return False return False
@ -142,6 +142,11 @@ class ConfigFolder:
def inform_missing_content(self, whatsmissing : str): def inform_missing_content(self, whatsmissing : str):
if whatsmissing == "": if whatsmissing == "":
return False return False
# Starting with cbpi 4.2.0, the craftbeerpi.service file will be created dynamically from the template file based on the user id.
# Therefore, the service file is replaced with a template file in the config folder
if whatsmissing.find("craftbeerpi.template"):
self.copyDefaultFileIfNotExists("craftbeerpi.template")
return False
print("***************************************************") print("***************************************************")
print(f"CraftBeerPi config content not found: {whatsmissing}") print(f"CraftBeerPi config content not found: {whatsmissing}")
print("Please run 'cbpi setup' before starting the server ") print("Please run 'cbpi setup' before starting the server ")

View file

@ -7,7 +7,7 @@ aiohttp-session==2.12.0
aiohttp-swagger==1.0.16 aiohttp-swagger==1.0.16
aiojobs==1.1.0 aiojobs==1.1.0
aiosqlite==0.17.0 aiosqlite==0.17.0
cryptography==41.0.3 cryptography==41.0.4
pyopenssl==23.2.0 pyopenssl==23.2.0
requests==2.31.0 requests==2.31.0
voluptuous==0.13.1 voluptuous==0.13.1

View file

@ -47,7 +47,7 @@ setup(name='cbpi4',
"aiohttp-swagger==1.0.16", "aiohttp-swagger==1.0.16",
"aiojobs==1.1.0 ", "aiojobs==1.1.0 ",
"aiosqlite==0.17.0", "aiosqlite==0.17.0",
"cryptography==41.0.3", "cryptography==41.0.4",
"pyopenssl==23.2.0", "pyopenssl==23.2.0",
"requests==2.31.0", "requests==2.31.0",
"voluptuous==0.13.1", "voluptuous==0.13.1",