def push_sms_to_queue(*args, **kwargs):
    """
       A sqs tasks that pulls sms from the queue
       and process it.
       Note: we have done we middleware sms client
       setting here as these are not set in the worker machine.
       and extra log can be removed after smooth trial
    """
    brand = kwargs.get("brand", None)
    phone_number = kwargs.get("phone_number", None)
    message = kwargs.get("message", None)
    source_client = kwargs.get("__gm_source", None)

    logger.info("brand:{0} , phone: {1}, message: {2} source: {3}".format(brand, phone_number, message, source_client))
    try:
        BRAND = settings.__dict__["_wrapped"].__class__.BRAND = make_tls_property()
        BRAND.value = brand
        SMS_CLIENT = settings.__dict__["_wrapped"].__class__.SMS_CLIENT = make_tls_property()

        logger.info("ENV: {0}".format(settings.ENV))
        if settings.ENV in ["local", "test", "staging"]:
            SMS_CLIENT.value = None
            return

        if source_client == settings.SMS_CLIENT_DETAIL["KAP"]["params"]:
            SMS_CLIENT.value = "KAP"
        else:
            try:
                SMS_CLIENT.value = settings.BRAND_SMS_GATEWAY.get(settings.BRAND)
            except:
                SMS_CLIENT.value = "AIRTEL"
        response = sms_processing(phone_number, message, brand)
        logger.info("[push_sms_to_queue]: {0}".format(response))
    except Exception as ex:
        logger.info("[Exception in push_sms_to_queue]: {0}".format(ex))
import logging

from django.http import HttpResponseBadRequest
from django.conf import settings

from gladminds.bajaj import models as common
from gladminds.core.managers import sms_parser
from gladminds.core.middlewares.dynamicsite_middleware import make_tls_property

logger = logging.getLogger('gladminds')

__all__ = ['GladmindsMiddleware', 'GladmindsMessageMiddleware']
SMS_CLIENT = settings.__dict__['_wrapped'].__class__.SMS_CLIENT =  make_tls_property()

"""
Gladminds middleware to identify the IP from where the message request came
and reply through the same platform
"""

class GladmindsMessageMiddleware(object):
    '''If the request is come on message APIs,
    then based on the IP we set sms client'''

    def process_request(self, request, **kwargs):
        source_client = request.GET.get('__gm_source', None)

        if settings.ENV in ['local', 'test', 'staging']:
            SMS_CLIENT.value = None
            return

        if source_client == settings.SMS_CLIENT_DETAIL['KAP']['params']: