More log output (#214)

* Update snapshot.py

* Update __init__.py

* Update snapshot.py

* Update snapshot.py

* fix lint
This commit is contained in:
Pascal Vizeli 2017-10-09 13:30:15 +02:00 committed by GitHub
parent 68566ee9e1
commit 2df4f80aa5
2 changed files with 10 additions and 2 deletions

View File

@ -197,6 +197,8 @@ class SnapshotsManager(object):
await snapshot.restore_folders()
# start homeassistant restore
_LOGGER.info("Full-Restore %s restore Home-Assistant",
snapshot.slug)
snapshot.restore_homeassistant(self.homeassistant)
task_hass = self.loop.create_task(
self.homeassistant.update(snapshot.homeassistant_version))
@ -279,6 +281,8 @@ class SnapshotsManager(object):
await snapshot.restore_folders(folders)
if homeassistant:
_LOGGER.info("Partial-Restore %s restore Home-Assistant",
snapshot.slug)
snapshot.restore_homeassistant(self.homeassistant)
tasks.append(self.homeassistant.update(
snapshot.homeassistant_version))

View File

@ -261,7 +261,8 @@ class Snapshot(object):
"""Async context to close a snapshot."""
# exists snapshot or exception on build
if self.tar_file.is_file() or exception_type is not None:
return self._tmp.cleanup()
self._tmp.cleanup()
return
# validate data
try:
@ -283,7 +284,6 @@ class Snapshot(object):
_LOGGER.error("Can't write snapshot.json")
self._tmp.cleanup()
self._tmp = None
async def import_addon(self, addon):
"""Add a addon into snapshot."""
@ -323,9 +323,11 @@ class Snapshot(object):
origin_dir = Path(self.config.path_hassio, name)
try:
_LOGGER.info("Snapshot folder %s", name)
with tarfile.open(snapshot_tar, "w:gz",
compresslevel=1) as tar_file:
tar_file.add(origin_dir, arcname=".")
_LOGGER.info("Snapshot folder %s done", name)
self._data[ATTR_FOLDERS].append(name)
except tarfile.TarError as err:
@ -352,8 +354,10 @@ class Snapshot(object):
remove_folder(origin_dir)
try:
_LOGGER.info("Restore folder %s", name)
with tarfile.open(snapshot_tar, "r:gz") as tar_file:
tar_file.extractall(path=origin_dir)
_LOGGER.info("Restore folder %s done", name)
except tarfile.TarError as err:
_LOGGER.warning("Can't restore folder %s -> %s", name, err)