forked from jonaswinkler/paperless-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added sanity checker management command for manual execution jonaswin…
- Loading branch information
jonaswinkler
committed
Feb 13, 2021
1 parent
ed478a1
commit 8b2965d
Showing
6 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/documents/management/commands/document_sanity_checker.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import logging | ||
from django.core.management.base import BaseCommand | ||
from documents.sanity_checker import check_sanity, SanityError, SanityWarning | ||
|
||
logger = logging.getLogger("paperless.management.sanity_checker") | ||
|
||
|
||
class Command(BaseCommand): | ||
|
||
help = """ | ||
This command checks your document archive for issues. | ||
""".replace(" ", "") | ||
|
||
def handle(self, *args, **options): | ||
|
||
messages = check_sanity(progress=True) | ||
|
||
if len(messages) == 0: | ||
logger.info("No issues found.") | ||
else: | ||
for msg in messages: | ||
if type(msg) == SanityError: | ||
logger.error(str(msg)) | ||
elif type(msg) == SanityWarning: | ||
logger.warning(str(msg)) | ||
else: | ||
logger.info((str(msg))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters