(self)
| 630 | return loc |
| 631 | |
| 632 | def getGeoipDb(self): |
| 633 | db_name = 'GeoLite2-City.mmdb' |
| 634 | |
| 635 | sys_db_paths = [] |
| 636 | if sys.platform == "linux": |
| 637 | sys_db_paths += ['/usr/share/GeoIP/' + db_name] |
| 638 | |
| 639 | data_dir_db_path = os.path.join(config.data_dir, db_name) |
| 640 | |
| 641 | db_paths = sys_db_paths + [data_dir_db_path] |
| 642 | |
| 643 | for path in db_paths: |
| 644 | if os.path.isfile(path) and os.path.getsize(path) > 0: |
| 645 | return path |
| 646 | |
| 647 | self.log.info("GeoIP database not found at [%s]. Downloading to: %s", |
| 648 | " ".join(db_paths), data_dir_db_path) |
| 649 | if self.downloadGeoLiteDb(data_dir_db_path): |
| 650 | return data_dir_db_path |
| 651 | return None |
| 652 | |
| 653 | def getPeerLocations(self, peers): |
| 654 | import maxminddb |
no test coverage detected