Пример #1
0
 def __init__(self):
     zip_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN.ZIP")
     bin_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN")
     if not bin_path.exists():
         zf = zipfile.ZipFile(zip_path)
         zf.extract('IP2LOCATION-LITE-DB3.BIN', data_storage_dir)
     IP2Location.__init__(self, bin_path)
Пример #2
0
def get_db_path():
    zip_path = data_storage_dir.joinpath('ip2location.zip')
    db_path = data_storage_dir.joinpath('ip2location.db')
    if db_path.exists():
        return db_path
    zf = zipfile.ZipFile(zip_path)
    zf.extract('ip2location.db', data_storage_dir)
    return db_path
Пример #3
0
 def __init__(self):
     zip_path = data_storage_dir.joinpath("IP2LOCATION-LITE-ASN.CSV.ZIP")
     csv_path = data_storage_dir.joinpath("IP2LOCATION-LITE-ASN.CSV")
     if csv_path.exists():
         asn_fp = open(csv_path)
     else:
         zf = zipfile.ZipFile(zip_path)
         zf.extract('IP2LOCATION-LITE-ASN.CSV', data_storage_dir)
         asn_fp = open(csv_path)
     self.data = []
     reader = csv.reader(asn_fp, delimiter=',', quotechar='"')
     for row in reader:
         e = Entry(row[0], row[1], row)
         self.data.append(e)
     asn_fp.close()
Пример #4
0
    def gen_names(self):
        path = data_storage_dir.joinpath('srv_prefixes.json')
        with open(path, encoding='utf-8', errors='ignore') as file:
            prefixes = json.load(file)
        names = map(lambda prefix: prefix + self.domain, prefixes)

        for name in names:
            self.names_que.put(name)
Пример #5
0
import zipfile
import IP2Location
from config.setting import data_storage_dir

zip_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN.ZIP")
bin_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN")
if not bin_path.exists():
    zf = zipfile.ZipFile(zip_path)
    zf.extract('IP2LOCATION-LITE-DB3.BIN', data_storage_dir)
IpGeoInfo = IP2Location.IP2Location(bin_path)