mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Changed the consumer into a loop
This commit is contained in:
parent
cb0f7393d6
commit
946dbf4ea0
@ -1,3 +1,4 @@
|
|||||||
|
import datetime
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
@ -12,6 +13,7 @@ from PIL import Image
|
|||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from documents.models import Document
|
from documents.models import Document
|
||||||
|
|
||||||
@ -27,6 +29,8 @@ class Command(BaseCommand):
|
|||||||
5. Delete the pdf and images
|
5. Delete the pdf and images
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
LOOP_TIME = 10 # Seconds
|
||||||
|
|
||||||
CONVERT = settings.CONVERT_BINARY
|
CONVERT = settings.CONVERT_BINARY
|
||||||
SCRATCH = settings.SCRATCH_DIR
|
SCRATCH = settings.SCRATCH_DIR
|
||||||
CONSUME = settings.CONSUMPTION_DIR
|
CONSUME = settings.CONSUMPTION_DIR
|
||||||
@ -52,8 +56,9 @@ class Command(BaseCommand):
|
|||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
self.loop()
|
self.loop()
|
||||||
time.sleep(10)
|
time.sleep(self.LOOP_TIME)
|
||||||
print(".")
|
if self.verbosity > 1:
|
||||||
|
print(".")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Exiting")
|
print("Exiting")
|
||||||
|
|
||||||
@ -140,7 +145,17 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
sender, title = self._parse_file_name(pdf)
|
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(
|
shutil.move(jpgs[0], os.path.join(
|
||||||
self.MEDIA_IMG, "{:07}.jpg".format(doc.pk)))
|
self.MEDIA_IMG, "{:07}.jpg".format(doc.pk)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user