Exemplo n.º 1
0
def track_pack(provider, track):
    response.headers['Access-Control-Allow-Origin'] = '*'
    if provider == 'ect':
        auth = (
            request.headers.get('x-correios-usuario'),
            request.headers.get('x-correios-senha'),
        )
        if auth == (None, None):
            auth = None

        try:
            historico = PackTracker.correios(track, auth=auth)
        except (AttributeError, ValueError):
            message = "404 Pacote %s nao encontrado" % track
            logger.exception(message)
        else:
            return format_result({
                'servico': provider,
                'codigo': track,
                'historico': historico,
            })
    else:
        message = '404 Servico %s nao encontrado' % provider
        logger.warning(message)
    return make_error(message)
Exemplo n.º 2
0
def track_pack(provider, track):
    if provider == 'ect':
        try:
            historico = PackTracker.correios(track)
        except (AttributeError, ValueError):
            message = "404 Pacote %s nao encontrado" % track
            logger.exception(message)
        else:
            return format_result({
                'servico': provider,
                'codigo': track,
                'historico': historico,
            })
    else:
        message = '404 Servico %s nao encontrado' % provider
        logger.warning(message)
    return make_error(message)
Exemplo n.º 3
0
def track_pack(provider, track):
    response.headers['Access-Control-Allow-Origin'] = '*'
    if provider == 'ect':
        try:
            historico = PackTracker.correios(track)
        except (AttributeError, ValueError):
            message = "404 Pacote %s nao encontrado" % track
            logger.exception(message)
        else:
            return format_result({
                'servico': provider,
                'codigo': track,
                'historico': historico,
            })
    else:
        message = '404 Servico %s nao encontrado' % provider
        logger.warning(message)
    return make_error(message)