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