[fix] Watch the mmsd folder instead of a test folder
This commit is contained in:
parent
e946a74a19
commit
f44adaf6f1
2 changed files with 4 additions and 7 deletions
9
mms2mail
9
mms2mail
|
@ -23,7 +23,6 @@ from messaging.mms.message import MMSMessage
|
||||||
from marrow.mailer import Mailer, Message
|
from marrow.mailer import Mailer, Message
|
||||||
|
|
||||||
class Watcher:
|
class Watcher:
|
||||||
DIRECTORY_TO_WATCH = "/home/alex/tmp"
|
|
||||||
mms_folder = f"{Path.home()}/.mms/modemmanager"
|
mms_folder = f"{Path.home()}/.mms/modemmanager"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -31,7 +30,7 @@ class Watcher:
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
event_handler = Handler()
|
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()
|
self.observer.start()
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
@ -62,12 +61,9 @@ class MMS2Mail:
|
||||||
self.config = configparser.ConfigParser()
|
self.config = configparser.ConfigParser()
|
||||||
self.config.read(f"{Path.home()}/.mms/modemmanager/mms2mail.ini")
|
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 = 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):
|
def convert(self, path):
|
||||||
|
self.mailer.start()
|
||||||
status = configparser.ConfigParser()
|
status = configparser.ConfigParser()
|
||||||
status.read_file(open(f"{path}.status"))
|
status.read_file(open(f"{path}.status"))
|
||||||
if 'downloaded' in status['info']['state'] or 'received' in status['info']['state']:
|
if 'downloaded' in status['info']['state'] or 'received' in status['info']['state']:
|
||||||
|
@ -96,6 +92,7 @@ class MMS2Mail:
|
||||||
filename = datacontent[1]['Name']
|
filename = datacontent[1]['Name']
|
||||||
message.attach(filename,data_part.data)
|
message.attach(filename,data_part.data)
|
||||||
self.mailer.send(message)
|
self.mailer.send(message)
|
||||||
|
self.mailer.stop()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[mail]
|
[mail]
|
||||||
mailbox = /var/mail/mobian
|
mailbox = /var/mail/mobian
|
||||||
account = mobian
|
account = mobian
|
||||||
domain = "mobian.lan"
|
domain = mobian.lan
|
||||||
attach_mms = false
|
attach_mms = false
|
||||||
|
|
Loading…
Reference in a new issue