Better structure

This commit is contained in:
Remy Moll
2022-04-17 22:32:56 +02:00
parent 0a6dde8c78
commit 0d76bcbb98
15 changed files with 310 additions and 58 deletions

View File

@@ -1,38 +0,0 @@
import logging
import keys
from peewee import SqliteDatabase
from persistence import article_models
from archiving_utils import runner as archive_runner
from mail_utils import runner as mail_runner
# Global logger setup:
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S')
logger = logging.getLogger("MailThread")
# Constant values...
DOWNLOADS_DB = "/app/file_storage/downloads.db"
# DB Setup:
article_models.set_db(SqliteDatabase(
DOWNLOADS_DB,
pragmas = {'journal_mode': 'wal'} # mutliple threads can access at once
))
mail_worker = mail_runner.MailSender(keys.MAIL_UNAME, keys.MAIL_PASSWORD, keys.MAIL_SENDER, keys.MAIL_RECIPIENT)
dl_worker = archive_runner.ArchivingThread(article_models, mail_worker)
dl_worker.start()
# Retroactively sends a message to DIRK for messages that were archived using slack, but when the mail-reply was not yet implemented
url_list = []
for url in url_list:
dl_worker.get_or_save(url)