Esempio n. 1
0
 def download(self):
     content = self.download_file()
     if self.db_type in ("ipv4", "ipv6", "GeoIP"):
         db_reader = open_mmdb_database(content)
         db_metadata = db_reader.metadata()
         db_reader.close()
         # Do not erase nb_netset in internal db, its retrieved in index.json
         if not self.internal:
             self.nb_netset = db_metadata.node_count
     else:
         self.nb_unique = len(content.decode('utf8').split("\n"))
     return content
Esempio n. 2
0
 def download_mmdb(self):
     """ Always call this method first, to be sure the MMDB is OK """
     content = self.download_file()
     if self.db_type in ("ipv4", "ipv6", "GeoIP"):
         try:
             return open_mmdb_database(content)
         except Exception as e:
             logger.error("Downloaded content is not a valid MMDB database")
             raise VultureSystemError(
                 "Downloaded content is not a valid MMDB database",
                 "download '{}'".format(self.url))
     else:
         return None