示例#1
0
def geo_by_addr(ip):
    try:
        geo = _geo_by_addr(ip)
    except Exception:
        geo = None

    if not geo:
        return

    rv = {}
    for k in "country_code", "city", "region":
        d = geo.get(k)
        if isinstance(d, bytes):
            d = d.decode("ISO-8859-1")
        rv[k] = d

    return rv
示例#2
0
def geo_by_addr(ip):
    try:
        geo = _geo_by_addr(ip)
    except Exception:
        geo = None

    if not geo:
        return

    rv = {}
    for k in 'country_code', 'city', 'region':
        d = geo.get(k)
        if isinstance(d, six.binary_type):
            d = d.decode('ISO-8859-1')
        rv[k] = d

    return rv
示例#3
0
文件: snuba.py 项目: Kayle009/sentry
def geo_by_addr(ip):
    try:
        geo = _geo_by_addr(ip)
    except Exception:
        geo = None

    if not geo:
        return

    rv = {}
    for k in 'country_code', 'city', 'region':
        d = geo.get(k)
        if isinstance(d, six.binary_type):
            d = d.decode('ISO-8859-1')
        rv[k] = d

    return rv