inline all messages

This commit is contained in:
timeshifter
2022-12-06 15:15:43 +01:00
parent 28963c3e64
commit 530a1e090a
6 changed files with 13 additions and 30 deletions
+3 -4
View File
@@ -4,7 +4,6 @@ from datetime import timedelta
from uuid import UUID
from .disk import Disk
from .messages import CANNOT_FIND_BACKUP_DRIVE, ALREADY_IMPORTED, NOT_IMPORTED
from .misc import MAPPER_PATH, DISK_BY_UUID
from .commands.zfs import ZFS
from .dataset import Dataset
@@ -39,7 +38,7 @@ class ExternalPool(Pool):
def import_(self) -> None:
"""Import a pool. Raise an error if the pool was previously imported."""
if self._imported:
raise ValueError(ALREADY_IMPORTED, self.name)
raise ValueError("Cannot import, already imported", self.name)
self._disk.decrypt()
ZPool.import_from_directory(self, MAPPER_PATH)
self._imported = True
@@ -47,7 +46,7 @@ class ExternalPool(Pool):
def export(self) -> None:
"""Export a previously imported pool. Raise an error if the pool was not previously imported."""
if not self._imported:
raise ValueError(NOT_IMPORTED, self.name)
raise ValueError("Cannot export, not imported", self.name)
ZPool.export(self)
self._disk.encrypt()
self._imported = False
@@ -73,7 +72,7 @@ class ExternalPool(Pool):
print(f"Found disk {pool_name}, {disk_uuid}")
return cls(pool_name, disk)
else:
raise FileNotFoundError(CANNOT_FIND_BACKUP_DRIVE)
raise FileNotFoundError("Could not find a backup drive")
def clean_old_snapshots(self) -> None:
print("Cleaning old snapshots")