Beispiel #1
0
import jinja2
import logging
import logging.config
import os

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

# the relay host to actually send the final message to (set debug=1 to see what
# the relay is saying to the log server).
settings.relay = Relay(host=settings.relay_config['host'], 
                       port=settings.relay_config['port'], debug=0)


settings.receiver = None


Router.defaults(**settings.router_defaults)
Router.load(settings.handlers + settings.queue_handlers)
Router.RELOAD=True

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

# if you have pyenchant and enchant installed then the template tests will do
# spell checking for you, but you need to tell pyenchant where to find itself
if 'PYENCHANT_LIBRARY_PATH' not in os.environ:
    os.environ['PYENCHANT_LIBRARY_PATH'] = '/opt/local/lib/libenchant.dylib'

Beispiel #2
0
from salmon import queue
from salmon.routing import Router
import logging
import logging.config
import os

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


Router.defaults(**{})
Router.load(['app.server'])
Router.RELOAD=False
Router.LOG_EXCEPTIONS=True
Router.UNDELIVERABLE_QUEUE=queue.Queue("run/undeliverable")
Beispiel #3
0
# Fake boot module for tests
from salmon.routing import Router

Router.defaults(host="localhost")
Router.load([])
Router.RELOAD = False
Router.LOG_EXCEPTIONS = False
Beispiel #4
0
from __future__ import print_function

from salmon.routing import Router, nolocking, route, route_like, state_key_generator, stateless


@state_key_generator
def simple_key_gen(module_name, message):
    return module_name


# common routing capture regexes go in here, you can override them in @route
Router.defaults(host="localhost",
                action="[a-zA-Z0-9]+",
                list_name="[a-zA-Z.0-9]+")


@route("(list_name)-(action)@(host)")
def START(message, list_name=None, action=None, host=None):
    print("START", message, list_name, action, host)
    if action == 'explode':
        print("EXPLODE!")
        raise RuntimeError("Exploded on purpose.")
    return CONFIRM


@route("(list_name)-confirm-(id_number)@(host)", id_number="[0-9]+")
def CONFIRM(message, list_name=None, id_number=None, host=None):
    print("CONFIRM", message, list_name, id_number, host)
    return POSTING

Beispiel #5
0
import logging
import logging.config
import os
import sys
from salmon import queue
from salmon.routing import Router
from salmon.server import SMTPReceiver, Relay, QueueReceiver

if "PERMEABILITY_ENV" in os.environ:
    import testing_settings
else:
    from tests import testing_settings

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

testing_settings.relay = Relay(host=testing_settings.relay_config['host'],
                       port=testing_settings.relay_config['port'], debug=1)
testing_settings.receiver = QueueReceiver(testing_settings.receiver_config['maildir'])

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