예제 #1
0
    def cmd_geoip(options):
        from tranny.service import geoip
        from tranny.app import Session
        from tranny.app import config

        engine = create_engine(config.get_db_uri())
        Session.configure(bind=engine)
        Base.metadata.create_all(bind=engine)

        db_file_path = geoip.fetch_update(download=options.nodownload)
        geoip.update(Session(), db_file_path)
예제 #2
0
파일: __init__.py 프로젝트: bobbintb/tranny
    def cmd_geoip(options):
        from tranny.service import geoip
        from tranny.app import Session
        from tranny.app import config

        engine = create_engine(config.get_db_uri())
        Session.configure(bind=engine)
        Base.metadata.create_all(bind=engine)

        db_file_path = geoip.fetch_update(download=options.nodownload)
        geoip.update(Session(), db_file_path)
예제 #3
0
    def test_geoip(self):
        session = Session()
        db_file_path = get_fixture("GeoIPCountryCSV.zip")
        self.assertTrue(geoip.update(session, db_file_path))
        self.assertEqual(10, session.query(geoip.models.GeoIP).count())

        self.assertEqual("AU", geoip.find_country(session, 16777217))
        self.assertEqual("AU", geoip.find_country(session, net.int2ip(16777217)))

        self.assertIsNone(geoip.find_country(session, 1000))
예제 #4
0
    def test_geoip(self):
        session = Session()
        db_file_path = get_fixture("GeoIPCountryCSV.zip")
        self.assertTrue(geoip.update(session, db_file_path))
        self.assertEqual(10, session.query(geoip.models.GeoIP).count())

        self.assertEqual("AU", geoip.find_country_code(session, 16777217))
        self.assertEqual("AU", geoip.find_country_code(session, net.int2ip(16777217)))

        self.assertIsNone(geoip.find_country_code(session, 1000))