Esempio n. 1
0
def rapidsms_handle_message(msg, incoming=True):
    """Simple Celery task to process messages via BlockingRouter."""

    logger = rapidsms_handle_message.get_logger()
    if incoming:
        direction_name = 'incoming'
    else:
        direction_name = 'outgoing'
    logger.debug('New %s message: %s' % (direction_name, msg))
    router = BlockingRouter()
    try:
        router.start()
        if incoming:
            router.incoming(msg)
        else:
            router.outgoing(msg)
        router.stop()
    except Exception, e:
        logger.exception(e)
Esempio n. 2
0
 def setUp(self):
     self.router = BlockingRouter(apps=[], backends={})
Esempio n. 3
0
# the rest of settings.py?
import stock.apps as _stock_apps
import equipment.apps as _equipment_apps
import info.apps as _info_apps
import contextual.app as _contextual_apps
RAPIDSMS_APP_BASES = (
    _stock_apps.StockLevel,
    _stock_apps.StockOut,
    _equipment_apps.EquipmentFailure,
    _equipment_apps.EquipmentRepaired,
    _info_apps.Help,
    _equipment_apps.FridgeTemperature,
)

# Configure the RapidSMS router based on RAPIDSMS_APP_BASES
from rapidsms.router.blocking import BlockingRouter
RAPIDSMS_ROUTER = BlockingRouter()
for app in RAPIDSMS_APP_BASES:
    RAPIDSMS_ROUTER.add_app(app)

# Assign operation codes to AppBase handlers.
SIM_OPERATION_CODES = {
    "SL": _stock_apps.StockLevel,
    "SE": _stock_apps.StockOut,
    "NF": _equipment_apps.EquipmentFailure,
    "RE": _equipment_apps.EquipmentRepaired,
    "HE": _info_apps.Help,
    "FT": _equipment_apps.FridgeTemperature,
    "FC": _contextual_apps.FacilityCode,
}