mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-27 13:15:31 +00:00
[Core] Add pygeoip dependency support
Provide support for the pure-python pygeoip as compiled GeoIP is not always available. Ref: https://dev.deluge-torrent.org/ticket/3271
This commit is contained in:
parent
9b97c74025
commit
65e5010e7f
3 changed files with 11 additions and 8 deletions
|
@ -41,7 +41,7 @@ All modules will require the [common](#common) section dependencies.
|
||||||
## Core (deluged daemon)
|
## Core (deluged daemon)
|
||||||
|
|
||||||
- [libtorrent] _>= 1.1.1_
|
- [libtorrent] _>= 1.1.1_
|
||||||
- [GeoIP] - Optional: IP address location lookup. (_Debian: `python-geoip`_)
|
- [GeoIP] or [pygeoip] - Optional: IP address country lookup. (_Debian: `python-geoip`_)
|
||||||
|
|
||||||
## GTK UI
|
## GTK UI
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,14 @@ import deluge.configmanager
|
||||||
from deluge._libtorrent import lt
|
from deluge._libtorrent import lt
|
||||||
from deluge.event import ConfigValueChangedEvent
|
from deluge.event import ConfigValueChangedEvent
|
||||||
|
|
||||||
|
GeoIP = None
|
||||||
try:
|
try:
|
||||||
import GeoIP
|
from GeoIP import GeoIP
|
||||||
except ImportError:
|
except ImportError:
|
||||||
GeoIP = None
|
try:
|
||||||
|
from pygeoip import GeoIP
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -456,11 +460,9 @@ class PreferencesManager(component.Component):
|
||||||
# Load the GeoIP DB for country look-ups if available
|
# Load the GeoIP DB for country look-ups if available
|
||||||
if os.path.exists(geoipdb_path):
|
if os.path.exists(geoipdb_path):
|
||||||
try:
|
try:
|
||||||
self.core.geoip_instance = GeoIP.open(
|
self.core.geoip_instance = GeoIP(geoipdb_path, 0)
|
||||||
geoipdb_path, GeoIP.GEOIP_STANDARD
|
except Exception as ex:
|
||||||
)
|
log.warning('GeoIP Unavailable: %s', ex)
|
||||||
except AttributeError:
|
|
||||||
log.warning('GeoIP Unavailable')
|
|
||||||
else:
|
else:
|
||||||
log.warning('Unable to find GeoIP database file: %s', geoipdb_path)
|
log.warning('Unable to find GeoIP database file: %s', geoipdb_path)
|
||||||
|
|
||||||
|
|
|
@ -12,3 +12,4 @@ certifi; sys_platform == 'win32'
|
||||||
windows-curses; sys_platform == 'win32'
|
windows-curses; sys_platform == 'win32'
|
||||||
zope.interface>=4.4.2
|
zope.interface>=4.4.2
|
||||||
distro; 'linux' in sys_platform or 'bsd' in sys_platform
|
distro; 'linux' in sys_platform or 'bsd' in sys_platform
|
||||||
|
pygeoip
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue