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