本文整理匯總了Python中GeoIP.GEOIP_STANDARD屬性的典型用法代碼示例。如果您正苦於以下問題:Python GeoIP.GEOIP_STANDARD屬性的具體用法?Python GeoIP.GEOIP_STANDARD怎麽用?Python GeoIP.GEOIP_STANDARD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類GeoIP
的用法示例。
在下文中一共展示了GeoIP.GEOIP_STANDARD屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import GeoIP [as 別名]
# 或者: from GeoIP import GEOIP_STANDARD [as 別名]
def __init__(self, conf=config, dat_file=MAXMIND_FILE):
try:
maxmind_file = config.get('Configuration', 'dat_file')
if maxmind_file[0] != "/":
maxmind_file = loc + maxmind_file
#print maxmind_file # DEBUG
self.gi = GeoIP.open(maxmind_file, GeoIP.GEOIP_STANDARD)
self.dat_file_success = True
except:
pass
if not self.dat_file_success:
try:
if dat_file[0] != "/":
dat_file = loc + dat_file
#print dat_file # DEBUG
self.gi = GeoIP.open(dat_file, GeoIP.GEOIP_STANDARD)
self.dat_file_success = True
except:
pass
示例2: __init__
# 需要導入模塊: import GeoIP [as 別名]
# 或者: from GeoIP import GEOIP_STANDARD [as 別名]
def __init__(self, **kwargs):
self.kwargs = kwargs
self.ASN_DB = os.getenv('ISOLATE_GEOIP_ASN', '/opt/auth/shared/geoip/GeoIPASNum.dat')
self.asn = GeoIP.open(self.ASN_DB, GeoIP.GEOIP_STANDARD)
示例3: _init_readers
# 需要導入模塊: import GeoIP [as 別名]
# 或者: from GeoIP import GEOIP_STANDARD [as 別名]
def _init_readers(self):
self.g1_asnum_reader = GeoIP.open(self.v1_asnum, GeoIP.GEOIP_STANDARD)
self.g1_city_reader = GeoIP.open(self.v1_city, GeoIP.GEOIP_STANDARD)
self.g1_country_reader = GeoIP.open(
self.v1_country,
GeoIP.GEOIP_STANDARD
)
示例4: ip2geo
# 需要導入模塊: import GeoIP [as 別名]
# 或者: from GeoIP import GEOIP_STANDARD [as 別名]
def ip2geo(ip):
gi = GeoIP.open(geoDBpath,GeoIP.GEOIP_STANDARD)
gs = gi.record_by_addr(ip)
return gs
示例5: TraceTarget
# 需要導入模塊: import GeoIP [as 別名]
# 或者: from GeoIP import GEOIP_STANDARD [as 別名]
def TraceTarget(target_ip,interface):
results = execute_command(["itrace","-i",interface,"-d",target_ip])
gi = GeoIP.open("/usr/local/share/GeoIP/GeoIPCity.dat",GeoIP.GEOIP_STANDARD)
i = 0
for line in results:
if not line is "":
#print line
lst = list(str(line).split())
if not lst[1]=="Timeout":
#remove "[" and "]" at start and end of the string
i = i + 1
ipadr = str(str(lst[1]).replace("[","")).replace("]","")
try:
gir = gi.record_by_addr(ipadr)
if gir != None:
r = [i, ipadr, gir['country_code'], gir['city'], round(float(gir['latitude']),2), round(float(gir['longitude']),2)]
else:
r = [i, ipadr, "N/A", "N/A", "N/A", "N/A"]
except:
r = [i, ipadr, "N/A", "N/A", "N/A", "N/A"]
print str(r[0]).ljust(4)+str(r[1]).ljust(17)+str(r[2]).ljust(6)+str(r[3]).ljust(30)+str(r[4]).rjust(10)+str(r[5]).rjust(10)
###############################################################################
# PROCESS HANDLER #
###############################################################################
示例6: geoIp
# 需要導入模塊: import GeoIP [as 別名]
# 或者: from GeoIP import GEOIP_STANDARD [as 別名]
def geoIp(IP):
#return urllib.urlopen("http://ip-api.com/json/" + str(IP))
gi = GeoIP.open("/usr/share/GeoIP/GeoIPCity.dat", GeoIP.GEOIP_STANDARD)
gir = gi.record_by_addr(IP)
print gir
return gir