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()))
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)
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)
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)