예제 #1
0
def _settings_loader():
    from lamson.routing import Router
    from lamson.server import Relay, SMTPReceiver
    from lamson import view, queue
    import logging
    import logging.config
    import jinja2

    settings = Settings()
    for attr_name in dir(django_settings):
        if attr_name.startswith("LAMSON_"):
            setattr(settings,
                    attr_name.split("LAMSON_")[1].lower(),
                    getattr(django_settings, attr_name))

    #logging.config.fileConfig("logging.conf")

    # the relay host to actually send the final message to
    #TODO make debug a parameter to the command
    if hasattr(settings, 'relay_config'):
        settings.relay = Relay(host=settings.relay_config['host'],
                               port=settings.relay_config['port'],
                               debug=1)

    # where to listen for incoming messages
    settings.receiver = SMTPReceiver(settings.receiver_config['host'],
                                     settings.receiver_config['port'])

    Router.defaults(**settings.router_defaults)
    Router.load(settings.handlers)
    #TODO make this a parameter to the command
    Router.RELOAD = True
    #TODO make run a parameter to the command
    Router.UNDELIVERABLE_QUEUE = queue.Queue("run/undeliverable")

    if hasattr(settings, 'template_config'):
        view.LOADER = jinja2.Environment(
            loader=jinja2.PackageLoader(settings.template_config['dir'],
                                        settings.template_config['module']))

    return settings
예제 #2
0
def _settings_loader():
    from lamson.routing import Router
    from lamson.server import Relay, SMTPReceiver
    from lamson import view, queue
    import logging
    import logging.config
    import jinja2

    settings = Settings()
    for attr_name in dir(django_settings):
    	if attr_name.startswith("LAMSON_"):
    		setattr(settings, attr_name.split("LAMSON_")[1].lower(),
             getattr(django_settings, attr_name))

    #logging.config.fileConfig("logging.conf")

    # the relay host to actually send the final message to
    #TODO make debug a parameter to the command
    if hasattr(settings, 'relay_config'):
        settings.relay = Relay(host=settings.relay_config['host'],
                               port=settings.relay_config['port'], debug=1)

    # where to listen for incoming messages
    settings.receiver = SMTPReceiver(settings.receiver_config['host'],
                                     settings.receiver_config['port'])

    Router.defaults(**settings.router_defaults)
    Router.load(settings.handlers)
    #TODO make this a parameter to the command
    Router.RELOAD=True
    #TODO make run a parameter to the command
    Router.UNDELIVERABLE_QUEUE=queue.Queue("run/undeliverable")

    if hasattr(settings, 'template_config'):
        view.LOADER = jinja2.Environment(
            loader=jinja2.PackageLoader(settings.template_config['dir'],
                                        settings.template_config['module']))

    return settings
예제 #3
0
파일: forward.py 프로젝트: 3kwa/lamson
from config import settings
from lamson.routing import Router
from lamson.server import Relay, QueueReceiver
from lamson import view
import logging
import logging.config
import jinja2

# configure logging to go to a log file
logging.config.fileConfig("config/logging.conf")

# the relay host to actually send the final message to
settings.relay = Relay(host=settings.relay_config['host'], 
                       port=settings.relay_config['port'], debug=1)

# where to listen for incoming messages
settings.receiver = QueueReceiver('run/undeliverable', settings.queue_config['sleep'])

Router.defaults(**settings.router_defaults)
Router.load(['lamson.handlers.forward'])
Router.RELOAD=True
Router.UNDELIVERABLE_QUEUE=None

view.LOADER = jinja2.Environment(
    loader=jinja2.PackageLoader(settings.template_config['dir'], 
                                settings.template_config['module']))

예제 #4
0
파일: mailconf.py 프로젝트: emulbreh/ecs
import os
import logging
import logging.config

from django.conf import settings

from lamson.routing import Router
from lamson.server import Relay, SMTPReceiver
from lamson import queue

import ecs.ecsmail.monkey

relay = Relay(host= settings.EMAIL_HOST, port= settings.EMAIL_PORT, starttls= settings.EMAIL_USE_TLS,
    username = settings.EMAIL_HOST_USER, password= settings.EMAIL_HOST_PASSWORD)
# Monkey Patch deliver so it will use ecsmail settings (and django backends)
relay.deliver = ecs.ecsmail.monkey.deliver 

receiver = SMTPReceiver(settings.ECSMAIL ['listen'], settings.ECSMAIL ['port'])

Router.defaults(host= '.+')
Router.load(settings.ECSMAIL ['handlers'])
Router.RELOAD = False
Router.UNDELIVERABLE_QUEUE = queue.Queue(settings.ECSMAIL ['queue_dir'])
예제 #5
0
from config import settings
from lamson.routing import Router
from lamson.server import Relay, SMTPReceiver, QueueReceiver
from lamson import view, queue
import logging
import logging.config
import jinja2

logging.config.fileConfig("config/logging.conf")

# the relay host to actually send the final message to
settings.relay = Relay(host=settings.relay_config['host'],
                       port=settings.relay_config['port'],
                       debug=1)

# where to listen for incoming messages
#settings.receiver = SMTPReceiver(settings.receiver_config['host'],
#                                 settings.receiver_config['port'])

# b0nd - include the maildir option we've set in settings.py
settings.receiver = QueueReceiver(settings.receiver_config['maildir'])

Router.defaults(**settings.router_defaults)
Router.load(settings.handlers)
Router.RELOAD = True
Router.UNDELIVERABLE_QUEUE = queue.Queue("run/undeliverable")

view.LOADER = jinja2.Environment(loader=jinja2.PackageLoader(
    settings.template_config['dir'], settings.template_config['module']))