Beispiel #1
0
 def main_loop(self, directory, loop_time):
     while True:
         start_time = time.time()
         import_attachment()  # imap importer
         import_documents(directory)  # local importer
         # Sleep until the start of the next loop step
         time.sleep(max(0, start_time + loop_time - time.time()))
Beispiel #2
0
 def test_multiple_files_local_importer(self):
     file_path_tar = os.path.join(BASE_DIR, "data", "testdata.tar")
     file_path_jpg = os.path.join(BASE_DIR, "data", "page-1.jpg")
     file_path_pdf = os.path.join(BASE_DIR, "data", "berlin.pdf")
     with tempfile.TemporaryDirectory() as tempdirname:
         shutil.copy(file_path_pdf, tempdirname)
         shutil.copy(file_path_jpg, tempdirname)
         shutil.copy(file_path_tar, tempdirname)
         import_documents(tempdirname, skip_ocr=True)
     self.assertEqual(Document.objects.count(), 2)
Beispiel #3
0
def import_from_local_folder():
    """
    Import documents from defined local folder
    """
    logger.debug("Celery beat: import_from_local_folder")
    import_documents(settings.PAPERMERGE_IMPORTER_DIR)
Beispiel #4
0
 def test_tar_local_importer(self):
     file_path = os.path.join(BASE_DIR, "data", "testdata.tar")
     with tempfile.TemporaryDirectory() as tempdirname:
         shutil.copy(file_path, tempdirname)
         import_documents(tempdirname, skip_ocr=True)
     self.assertEqual(Document.objects.count(), 0)