mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-21 14:38:15 +01:00
handling in case of error (config controller -> remove)
This commit is contained in:
parent
dc36cc1ed3
commit
5e69ce4c40
2 changed files with 9 additions and 5 deletions
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.1.8.a6"
|
__version__ = "4.1.8.a7"
|
||||||
__codename__ = "Groundhog Day"
|
__codename__ = "Groundhog Day"
|
||||||
|
|
||||||
|
|
|
@ -61,16 +61,20 @@ class ConfigController:
|
||||||
async def remove(self, name):
|
async def remove(self, name):
|
||||||
data = {}
|
data = {}
|
||||||
self.testcache={}
|
self.testcache={}
|
||||||
|
success=False
|
||||||
for key, value in self.cache.items():
|
for key, value in self.cache.items():
|
||||||
try:
|
try:
|
||||||
if key != name:
|
if key != name:
|
||||||
data[key] = value.to_dict()
|
data[key] = value.to_dict()
|
||||||
self.testcache[key] = Config(name=data[key].get("name"), value=data[key].get("value"), description=data[key].get("description"),
|
self.testcache[key] = Config(name=data[key].get("name"), value=data[key].get("value"), description=data[key].get("description"),
|
||||||
type=ConfigType(data[key].get("type", "string")), options=data[key].get("options", None),
|
type=ConfigType(data[key].get("type", "string")), options=data[key].get("options", None),
|
||||||
source=data[key].get("source", "craftbeerpi") )
|
source=data[key].get("source", "craftbeerpi") )
|
||||||
|
success=True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
with open(self.path, "w") as file:
|
success=False
|
||||||
json.dump(data, file, indent=4, sort_keys=True)
|
if success == True:
|
||||||
self.cache=self.testcache
|
with open(self.path, "w") as file:
|
||||||
|
json.dump(data, file, indent=4, sort_keys=True)
|
||||||
|
self.cache=self.testcache
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue