refactor: exit code constants

This commit is contained in:
timeshifter
2021-12-02 15:18:33 +01:00
parent c59fef4e95
commit f28df3e4c6
+5 -4
View File
@@ -13,6 +13,8 @@ from uuid import UUID
import config
EXIT_ERROR = 1
ALREADY_DECRYPTED = "Cannot decrypt, already decrypted"
ALREADY_IMPORTED = "Cannot import, already imported"
CANNOT_FIND_BACKUP_DRIVE = "Could not find a backup drive"
@@ -322,8 +324,7 @@ class Disk:
for item in MAPPER_PATH.iterdir():
if self._mapper_entry == item.name:
print(MAPPER_ENTRY_ALREADY_EXISTS, self._mapper_entry)
# TODO exit code constants
exit(1)
exit(EXIT_ERROR)
@property
def _path(self) -> Path:
@@ -394,7 +395,7 @@ class ExternalPool(Pool):
return cls(pool_name, disk)
else:
print(CANNOT_FIND_BACKUP_DRIVE)
exit(1)
exit(EXIT_ERROR)
def clean_old_snapshots(self):
print("Cleaning old snapshots")
@@ -501,7 +502,7 @@ class Command:
def verify_running_as_root():
if getuid() > 0:
print(RUN_AS_ROOT)
exit(1)
exit(EXIT_ERROR)
if __name__ == "__main__":