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
+4 -5
View File
@@ -3,7 +3,6 @@ from __future__ import annotations
from pathlib import Path
from ._core import CommandInterface
from ..messages import MAPPER_ENTRY_ALREADY_EXISTS, CANNOT_FIND_DEVICE_PATH
from ..misc import MAPPER_PATH, DISK_BY_UUID
@@ -31,8 +30,7 @@ class Cryptsetup(CommandInterface):
if cls._mapper_entry_in_use(mapper_entry):
if cls._already_decrypted(path, mapper_entry):
return True
print(MAPPER_ENTRY_ALREADY_EXISTS)
raise FileExistsError()
raise FileExistsError("mapper entry already exists")
cls._run_command(cls._Subcommands.open, str(path), mapper_entry)
return False
@@ -71,8 +69,9 @@ class Cryptsetup(CommandInterface):
device = Path(line.split(":")[-1].strip())
break
else:
raise FileNotFoundError(CANNOT_FIND_DEVICE_PATH)
# noinspection PyUnboundLocalVariable
raise FileNotFoundError(
"Cannot find device path from output of `cryptsetup status`"
)
return device
@classmethod
+3 -2
View File
@@ -6,7 +6,6 @@ from subprocess import Popen
from .. import Pool
from ._core import CommandInterface
from ..dataset import Dataset
from ..messages import SAME_DATASET
from ..misc import assert_type
from ..snapshot import Snapshot
from ..zfs_path import ZFSPath
@@ -90,7 +89,9 @@ class ZFS(CommandInterface):
f"Cannot send stream, object is not a Snapshot: {snapshot}",
)
if old_snapshot.dataset != new_snapshot.dataset:
raise ValueError(SAME_DATASET)
raise ValueError(
"Cannot send incremental snapshots if start and end snapshot are not based on the same dataset"
)
if old_snapshot.newer_than(new_snapshot):
raise ValueError("Old snapshot is newer than new snapshot.")
if old_snapshot == new_snapshot: