[fix] Watch the mmsd folder instead of a test folder

This commit is contained in:
Alex 2021-05-01 10:28:31 +02:00
parent e946a74a19
commit f44adaf6f1
2 changed files with 4 additions and 7 deletions

View file

@ -23,7 +23,6 @@ from messaging.mms.message import MMSMessage
from marrow.mailer import Mailer, Message
class Watcher:
DIRECTORY_TO_WATCH = "/home/alex/tmp"
mms_folder = f"{Path.home()}/.mms/modemmanager"
def __init__(self):
@ -31,7 +30,7 @@ class Watcher:
def run(self):
event_handler = Handler()
self.observer.schedule(event_handler, self.DIRECTORY_TO_WATCH, recursive=False)
self.observer.schedule(event_handler, self.mms_folder, recursive=False)
self.observer.start()
try:
while True:
@ -62,12 +61,9 @@ class MMS2Mail:
self.config = configparser.ConfigParser()
self.config.read(f"{Path.home()}/.mms/modemmanager/mms2mail.ini")
self.mailer = Mailer({'manager.use': 'immediate', 'transport.use': 'mbox', 'transport.file': self.config.get('mail','mailbox', fallback=f"/var/mail/{getpass.getuser()}")})
self.mailer.start()
def __del__(self):
self.mailer.stop()
def convert(self, path):
self.mailer.start()
status = configparser.ConfigParser()
status.read_file(open(f"{path}.status"))
if 'downloaded' in status['info']['state'] or 'received' in status['info']['state']:
@ -96,6 +92,7 @@ class MMS2Mail:
filename = datacontent[1]['Name']
message.attach(filename,data_part.data)
self.mailer.send(message)
self.mailer.stop()
if __name__ == '__main__':
parser = argparse.ArgumentParser()

View file

@ -1,5 +1,5 @@
[mail]
mailbox = /var/mail/mobian
account = mobian
domain = "mobian.lan"
domain = mobian.lan
attach_mms = false