A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Changed the consumer into a loop
Daniel Quinn946dbf4ea040
diff --git a/src/documents/management/commands/consume.py b/src/documents/management/commands/consume.pyindex 3ab655712..b48f5b6be 100644--- a/src/documents/management/commands/consume.py+++ b/src/documents/management/commands/consume.py@@ -1,3 +1,4 @@+import datetimeimport globimport osimport random@@ -12,6 +13,7 @@ from PIL import Imagefrom django.conf import settingsfrom django.core.management.base import BaseCommand+from django.utils import timezonefrom documents.models import Document@@ -27,6 +29,8 @@ class Command(BaseCommand):5. Delete the pdf and images"""+ LOOP_TIME = 10 # Seconds+CONVERT = settings.CONVERT_BINARYSCRATCH = settings.SCRATCH_DIRCONSUME = settings.CONSUMPTION_DIR@@ -52,8 +56,9 @@ class Command(BaseCommand):try:while True:self.loop()- time.sleep(10)- print(".")+ time.sleep(self.LOOP_TIME)+ if self.verbosity > 1:+ print(".")except KeyboardInterrupt:print("Exiting")@@ -140,7 +145,17 @@ class Command(BaseCommand):sender, title = self._parse_file_name(pdf)- doc = Document.objects.create(sender=sender, title=title, content=text)+ stats = os.stat(pdf)++ doc = Document.objects.create(+ sender=sender,+ title=title,+ content=text,+ created=timezone.make_aware(+ datetime.datetime.fromtimestamp(stats.st_ctime)),+ modified=timezone.make_aware(+ datetime.datetime.fromtimestamp(stats.st_mtime)),+ )shutil.move(jpgs[0], os.path.join(self.MEDIA_IMG, "{:07}.jpg".format(doc.pk)))