本文整理匯總了Python中router.Router.add_backend方法的典型用法代碼示例。如果您正苦於以下問題:Python Router.add_backend方法的具體用法?Python Router.add_backend怎麽用?Python Router.add_backend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類router.Router
的用法示例。
在下文中一共展示了Router.add_backend方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: start
# 需要導入模塊: from router import Router [as 別名]
# 或者: from router.Router import add_backend [as 別名]
def start (args):
# if a specific conf has been provided (which it
# will be), if we're inside the django reloaded
if "RAPIDSMS_INI" in os.environ:
ini = os.environ["RAPIDSMS_INI"]
# use a local ini (for development)
# if one exists, to avoid everyone
# having their own rapidsms.ini
elif os.path.isfile("local.ini"):
ini = "local.ini"
# otherwise, fall back
else: ini = "rapidsms.ini"
# add the ini path to the environment, so we can
# access it globally, including any subprocesses
# spawned by django
os.environ["RAPIDSMS_INI"] = ini
# read the config, which is shared
# between the back and frontend
conf = Config(ini)
# import the webui settings, which builds the django
# config from rapidsms.config, in a round-about way.
# can't do it until env[RAPIDSMS_INI] is defined
from rapidsms.webui import settings
# whatever we're doing, we'll need to call
# django's setup_environ, to configure the ORM
os.environ["DJANGO_SETTINGS_MODULE"] = "rapidsms.webui.settings"
from django.core.management import setup_environ, execute_manager
setup_environ(settings)
# if one or more arguments were passed, we're
# starting up django -- copied from manage.py
if len(args) > 1:
execute_manager(settings)
# no arguments passed, so perform
# the default action: START RAPIDSMS
else:
router = Router()
router.set_logger(conf["log"]["level"], conf["log"]["file"])
router.info("RapidSMS Server started up")
# add each application from conf
for app_conf in conf["rapidsms"]["apps"]:
router.add_app(app_conf)
# add each backend from conf
for backend_conf in conf["rapidsms"]["backends"]:
router.add_backend(backend_conf)
# wait for incoming messages
router.start()
示例2: route
# 需要導入模塊: from router import Router [as 別名]
# 或者: from router.Router import add_backend [as 別名]
def route (self, conf, *args):
router = Router()
router.set_logger(conf["log"]["level"], conf["log"]["file"])
router.info("RapidSMS Server started up")
# add each application from conf
for app_conf in conf["rapidsms"]["apps"]:
router.add_app(app_conf)
# add each backend from conf
for backend_conf in conf["rapidsms"]["backends"]:
router.add_backend(backend_conf)
# wait for incoming messages
router.start()
示例3: route
# 需要導入模塊: from router import Router [as 別名]
# 或者: from router.Router import add_backend [as 別名]
def route (self, conf, *args):
router = Router()
router.set_logger(conf["log"]["level"], conf["log"]["file"])
router.info("RapidSMS Server started up")
# add each application from conf
for app_conf in conf["rapidsms"]["apps"]:
router.add_app(app_conf)
# add each backend from conf
for backend_conf in conf["rapidsms"]["backends"]:
router.add_backend(backend_conf)
# wait for incoming messages
router.start()
# TODO: Had to explicitly do this to end the script. Will need a fix.
sys.exit(0)
示例4: route
# 需要導入模塊: from router import Router [as 別名]
# 或者: from router.Router import add_backend [as 別名]
def route (self, conf, *args):
router = Router()
router.set_logger(conf["log"]["level"], conf["log"]["file"])
router.info("RapidSMS Server started up")
# even though we have the original rapidsms conf, iterate
# the running apps through the django settings, since app
# dependencies will be managed there (by depends.py). also,
# i'm trying to ignore the .ini file so hard that it dies
from rapidsms.djangoproject.settings import RAPIDSMS_APPS, RAPIDSMS_BACKENDS
# add each application from conf
for app_conf in RAPIDSMS_APPS.values():
router.add_app(app_conf)
# add each backend from conf
for backend_conf in RAPIDSMS_BACKENDS.values():
router.add_backend(backend_conf)
# wait for incoming messages
router.start()