Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pygeoip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pygeoip
Commits
33b76faf
Commit
33b76faf
authored
Oct 09, 2014
by
William Tisäter
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70 from oschwald/netspeed-cell
Add support for NetSpeedCell databases
parents
e8136328
d0f84176
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
+27
-1
pygeoip/__init__.py
+12
-1
tests/test_netspeed_cell.py
+15
-0
No files found.
pygeoip/__init__.py
View file @
33b76faf
...
...
@@ -168,6 +168,8 @@ class GeoIP(object):
const
.
CITY_EDITION_REV1_V6
,
const
.
ORG_EDITION
,
const
.
ISP_EDITION
,
const
.
NETSPEED_EDITION_REV1
,
const
.
NETSPEED_EDITION_REV1_V6
,
const
.
ASNUM_EDITION
,
const
.
ASNUM_EDITION_V6
):
self
.
_databaseSegments
=
0
...
...
@@ -455,7 +457,15 @@ class GeoIP(object):
:arg addr: IP address (e.g. 203.0.113.30)
"""
if
self
.
_databaseType
==
const
.
NETSPEED_EDITION
:
return
const
.
NETSPEED_NAMES
[
self
.
id_by_addr
(
addr
)]
elif
self
.
_databaseType
in
(
const
.
NETSPEED_EDITION_REV1
,
const
.
NETSPEED_EDITION_REV1_V6
):
ipnum
=
util
.
ip2long
(
addr
)
return
self
.
_get_org
(
ipnum
)
raise
GeoIPError
(
'Invalid database type, expected NetSpeed or NetSpeedCell'
)
def
netspeed_by_name
(
self
,
hostname
):
"""
...
...
@@ -498,7 +508,8 @@ class GeoIP(object):
:arg addr: IP address (e.g. 203.0.113.30)
"""
valid
=
(
const
.
ORG_EDITION
,
const
.
ISP_EDITION
,
const
.
ASNUM_EDITION
,
const
.
ASNUM_EDITION_V6
)
valid
=
(
const
.
ORG_EDITION
,
const
.
ISP_EDITION
,
const
.
ASNUM_EDITION
,
const
.
ASNUM_EDITION_V6
)
if
self
.
_databaseType
not
in
valid
:
message
=
'Invalid database type, expected Org, ISP or ASNum'
raise
GeoIPError
(
message
)
...
...
tests/test_netspeed_cell.py
0 → 100644
View file @
33b76faf
# -*- coding: utf-8 -*-
import
unittest
import
pygeoip
from
tests.config
import
NETSPEEDCELL_DB_PATH
class
TestGeoIPNetspeedCellFunctions
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
gi
=
pygeoip
.
GeoIP
(
NETSPEEDCELL_DB_PATH
)
def
testNetSpeedByAddrWrapper
(
self
):
netspeed
=
self
.
gi
.
netspeed_by_addr
(
'2.125.160.1'
)
self
.
assertEqual
(
netspeed
,
'Dialup'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment