Restore config fix for windows

This commit is contained in:
avollkopf 2022-01-25 11:33:21 +01:00
parent 8320853399
commit 50677a2a3e
2 changed files with 11 additions and 5 deletions

View file

@ -1 +1 @@
__version__ = "4.0.1.4"
__version__ = "4.0.1.5"

View file

@ -10,6 +10,7 @@ from cbpi.utils.utils import load_config
from zipfile import ZipFile
from cbpi.craftbeerpi import CraftBeerPi
import os
import platform
import pathlib
import shutil
import yaml
@ -152,14 +153,19 @@ def check_for_setup():
if zip_content == True:
print("Found correct content. Starting Restore process")
output_path = pathlib.Path(os.path.join(".", 'config'))
owner = output_path.owner()
group = output_path.group()
system = platform.system()
print(system)
if system != "Windows":
owner = output_path.owner()
group = output_path.group()
print("Removing old config folder")
shutil.rmtree(output_path, ignore_errors=True)
print("Extracting zip file to config folder")
zip.extractall(output_path)
print("Changing owner and group of config folder recursively to {}:{}".format(owner,group))
recursive_chown(output_path, owner, group)
zip.close()
if system != "Windows":
print("Changing owner and group of config folder recursively to {}:{}".format(owner,group))
recursive_chown(output_path, owner, group)
print("Removing backup file")
os.remove(backupfile)
else: