当前位置: 首页>>代码示例>>Python>>正文


Python Router.load方法代码示例

本文整理汇总了Python中salmon.routing.Router.load方法的典型用法代码示例。如果您正苦于以下问题:Python Router.load方法的具体用法?Python Router.load怎么用?Python Router.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在salmon.routing.Router的用法示例。


在下文中一共展示了Router.load方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_routes_deliver_to_not_existing_address

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
    def test_routes_deliver_to_not_existing_address(self):
        Router.load(['inboxen.router.app.server'])

        message = MailRequest("locahost", "[email protected]", "[email protected]", TEST_MSG)
        with self.assertRaises(SMTPError) as excp:
            Router.deliver(message)
        self.assertEqual(excp.exception.code, 550)
        self.assertEqual(excp.exception.message, "No such address")
开发者ID:Inboxen,项目名称:Inboxen,代码行数:10,代码来源:tests.py

示例2: test_routes_deliver_to_admin_raise_smtperror_on_other_errors

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
    def test_routes_deliver_to_admin_raise_smtperror_on_other_errors(self):
        Router.load(['inboxen.router.app.server'])

        with mock.patch("salmon.server.smtplib.SMTP") as smtp_mock:
            smtp_mock.return_value.sendmail.side_effect = Exception()
            message = MailRequest("locahost", "[email protected]", "[email protected]", TEST_MSG)

            with self.assertRaises(SMTPError) as excp:
                Router.deliver(message)
            self.assertEqual(excp.exception.code, 450)
            self.assertEqual(excp.exception.message, "Error while forwarding admin message %s" % id(message))
开发者ID:Inboxen,项目名称:Inboxen,代码行数:13,代码来源:tests.py

示例3: test_routes_deliver_to_admin

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
    def test_routes_deliver_to_admin(self):
        Router.load(['inboxen.router.app.server'])

        with mock.patch("inboxen.router.app.server.Relay") as relay_mock, \
                mock.patch("inboxen.router.app.server.make_email") as mock_make_email:
            deliver_mock = mock.Mock()
            relay_mock.return_value.deliver = deliver_mock
            message = MailRequest("locahost", "[email protected]", "[email protected]", TEST_MSG)
            Router.deliver(message)

            self.assertEqual(mock_make_email.call_count, 0)
            self.assertEqual(relay_mock.call_count, 1)
            self.assertEqual(deliver_mock.call_count, 1)
            self.assertEqual(message, deliver_mock.call_args[0][0])
开发者ID:Inboxen,项目名称:Inboxen,代码行数:16,代码来源:tests.py

示例4: test_routes_deliver_to_inbox

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
    def test_routes_deliver_to_inbox(self):
        user = factories.UserFactory()
        inbox = factories.InboxFactory(user=user)
        Router.load(['inboxen.router.app.server'])

        with mock.patch("inboxen.router.app.server.Relay") as relay_mock, \
                mock.patch("inboxen.router.app.server.make_email") as mock_make_email:
            deliver_mock = mock.Mock()
            relay_mock.return_value.deliver = deliver_mock
            message = MailRequest("locahost", "[email protected]", str(inbox), TEST_MSG)
            Router.deliver(message)

            self.assertEqual(mock_make_email.call_count, 1)
            self.assertEqual(relay_mock.call_count, 0)
            self.assertEqual(deliver_mock.call_count, 0)
开发者ID:Inboxen,项目名称:Inboxen,代码行数:17,代码来源:tests.py

示例5: test_reload_raises

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
def test_reload_raises():
    Router.LOG_EXCEPTIONS = True
    Router.reload()
    assert routing.LOG.exception.called

    Router.LOG_EXCEPTIONS = False
    routing.LOG.exception.reset_mock()
    assert_raises(ImportError, Router.reload)
    assert not routing.LOG.exception.called

    routing.LOG.exception.reset_mock()
    Router.LOG_EXCEPTIONS = True
    Router.load(['fake.handler'])
    assert routing.LOG.exception.called

    Router.LOG_EXCEPTIONS = False
    routing.LOG.exception.reset_mock()
    assert_raises(ImportError, Router.load, ['fake.handler'])
    assert not routing.LOG.exception.called
开发者ID:secretario,项目名称:salmon,代码行数:21,代码来源:routing_tests.py

示例6: to

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
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'

开发者ID:claytondaley,项目名称:salmon,代码行数:31,代码来源:testing.py

示例7: setup

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
def setup():
    Router.clear_routes()
    Router.clear_states()
    Router.load(['salmon_tests.simple_fsm_mod'])
开发者ID:yamatt,项目名称:salmon,代码行数:6,代码来源:testing_tests.py

示例8: SMTPReceiver

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
from config import settings
from salmon import queue
from salmon.routing import Router
from salmon.server import SMTPReceiver
import logging
import logging.config

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

# 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)
Router.RELOAD=False
Router.LOG_EXCEPTIONS=True
Router.UNDELIVERABLE_QUEUE=queue.Queue("run/undeliverable")
开发者ID:Inboxen,项目名称:router,代码行数:20,代码来源:boot.py

示例9:

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
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")
开发者ID:cloudfleet,项目名称:despatch,代码行数:16,代码来源:boot.py

示例10:

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
##

import logging
import logging.config
import os

from django.conf import settings as dj_settings
from salmon import queue
from salmon.routing import Router

from inboxen.router.config import settings

__all__ = ["settings"]

try:
    os.mkdir("logs", 0o700)
except OSError:
    pass

try:
    os.mkdir("run", 0o710)  # group can access files in "run"
except OSError:
    pass

logging.config.dictConfig(dj_settings.SALMON_LOGGING)

Router.load(['inboxen.router.app.server'])
Router.RELOAD = False
Router.LOG_EXCEPTIONS = True
Router.UNDELIVERABLE_QUEUE = queue.Queue("run/undeliverable")
开发者ID:Inboxen,项目名称:Inboxen,代码行数:32,代码来源:boot.py

示例11: setup_router

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
def setup_router(handlers):
    Router.clear_routes()
    Router.clear_states()
    Router.HANDLERS.clear()
    Router.load(handlers)
开发者ID:moggers87,项目名称:salmon,代码行数:7,代码来源:setup_env.py

示例12: SMTPReceiver

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
import logging
import logging.config

from salmon import queue
from salmon.routing import Router
from salmon.server import SMTPReceiver

from . import settings

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

settings.receiver = SMTPReceiver(**settings.receiver_config)

Router.defaults(**settings.router_defaults)
Router.load(settings.dump_handlers)
Router.RELOAD = True
Router.UNDELIVERABLE_QUEUE = queue.Queue(settings.UNDELIVERABLE_QUEUE)
开发者ID:moggers87,项目名称:salmon,代码行数:19,代码来源:dump.py

示例13: QueueReceiver

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
logging.config.fileConfig("config/logging.conf")

settings.receiver = QueueReceiver(settings.SENDER_QUEUE_PATH,
                                  settings.sender_queue_sleep)

# 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)

# when silent, it won't reply to emails it doesn't know
settings.silent = settings.is_silent_config

# owner email to send all unknown emails
settings.owner_email = settings.owner_email_config

# server for email
settings.server_name = settings.server_name_config

# server for website
settings.web_server_name = settings.server_name_config

# start backend
table.r = table.start_table()

Router.defaults(**settings.router_defaults)
Router.load(settings.sender_handlers)
Router.RELOAD=True
Router.SEND_QUEUE=queue.Queue(settings.SENDER_QUEUE_PATH) # mails to send
Router.UNDELIVERABLE_QUEUE=queue.Queue("run/error_send")
Router.STATE_STORE=state_storage.UserStateStorage()
开发者ID:DrDub,项目名称:poissonmagique,代码行数:32,代码来源:sender.py

示例14: Relay

# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import load [as 别名]
from config import settings
from salmon.routing import Router
from salmon.server import Relay, QueueReceiver
from salmon 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(['salmon.handlers.forward'])
Router.RELOAD=True
Router.UNDELIVERABLE_QUEUE=None

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

开发者ID:claytondaley,项目名称:salmon,代码行数:28,代码来源:forward.py


注:本文中的salmon.routing.Router.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。