Exemplo n.º 1
0
def catch_signal(app, **kwargs):
    app_name = app.__name__.rsplit('.', 1)[0]
    if app_name == _module:
        def _log(msg):
            if not settings.DEBUG:
                logging.exception(msg)
            else:
                print(msg, file=sys.stderr)

        try:
            q = {'fields': ['name']}
            result = es_query(params={
                'internal.using_call_center': True,
                'is_active': True,
                'is_snapshot': False
            }, q=q)
            hits = result.get('hits', {}).get('hits', {})
            for hit in hits:
                try:
                    domain = Domain.get(hit['_id'])
                    print('  callcenter bootstap `{0}`'.format(domain.name))
                    bootstrap_callcenter(domain)
                except ResourceNotFound:
                    _log("Couldn't find domain {dom} during call center sync".format(dom=hit['_id']))

        except (RequestException, ESError):
            _log('Unable to query ES for call-center domains during syncdb')
Exemplo n.º 2
0
def catch_signal(app, **kwargs):
    app_name = app.__name__.rsplit('.', 1)[0]
    if app_name == _module:

        def _log(msg):
            if not settings.DEBUG:
                logging.exception(msg)
            else:
                print(msg, file=sys.stderr)

        try:
            q = {'fields': ['name']}
            result = es_query(params={
                'internal.using_call_center': True,
                'is_active': True,
                'is_snapshot': False
            },
                              q=q)
            hits = result.get('hits', {}).get('hits', {})
            for hit in hits:
                try:
                    domain = Domain.get(hit['_id'])
                    print('  callcenter bootstap `{0}`'.format(domain.name))
                    bootstrap_callcenter(domain)
                except ResourceNotFound:
                    _log("Couldn't find domain {dom} during call center sync".
                         format(dom=hit['_id']))

        except RequestException:
            _log('Unable to query ES for call-center domains during syncdb')
Exemplo n.º 3
0
def catch_signal(app, **kwargs):
    app_name = app.__name__.rsplit(".", 1)[0]
    if app_name == _module:
        from corehq.apps.appstore.views import es_query

        try:
            q = {"fields": ["name"]}
            result = es_query(params={"internal.using_call_center": True, "is_active": True, "is_snapshot": False}, q=q)
            hits = result.get("hits", {}).get("hits", {})
            for hit in hits:
                domain = Domain.get(hit["_id"])
                print("  callcenter bootstap `{}`".format(domain.name))
                bootstrap_callcenter(domain)
        except RequestException:
            if not settings.DEBUG:
                logging.exception("Unable to query ES for call-center domains during syncdb")
            else:
                print("WARNING: unable to query ES for call-center domains", file=sys.stderr)
Exemplo n.º 4
0
def catch_signal(app, **kwargs):
    app_name = app.__name__.rsplit('.', 1)[0]
    if app_name == _module:

        def _log(msg):
            if not settings.DEBUG:
                logging.exception(msg)
            else:
                print(msg, file=sys.stderr)

        try:
            domains = get_call_center_domains()
        except (RequestException, ESError):
            _log('Unable to query ES for call-center domains during syncdb')
            domains = []

        for name in domains:
            domain = Domain.get_by_name(name)
            if domain:
                print('  callcenter bootstap `{0}`'.format(domain.name))
                bootstrap_callcenter(domain)
Exemplo n.º 5
0
def catch_signal(app, **kwargs):
    if settings.UNIT_TESTING:
        return

    app_name = app.__name__.rsplit('.', 1)[0]
    if app_name == _module:
        def _log(msg):
            if not settings.DEBUG:
                logging.exception(msg)
            else:
                print(msg, file=sys.stderr)

        try:
            domains = get_call_center_domains()
        except (RequestException, ESError):
            _log('Unable to query ES for call-center domains during syncdb')
            domains = []

        for name in domains:
            domain = Domain.get_by_name(name)
            if domain:
                print('  callcenter bootstap `{0}`'.format(domain.name))
                bootstrap_callcenter(domain)
Exemplo n.º 6
0
def bootstrap_callcenter_domain_signal(sender, **kwargs):
    return bootstrap_callcenter(kwargs['domain'])
Exemplo n.º 7
0
def bootstrap_callcenter_domain_signal(sender, **kwargs):
    return bootstrap_callcenter(kwargs['domain'])