#3271: Support pygeoip for ip lookups
-------------------+-------------------
Reporter: Cas | Owner:
Type: bug | Status: new
Priority: minor | Milestone: 2.0.4
Component: Core | Version: 2.0.0
Keywords: |
-------------------+-------------------
Alpine linux only packages the pure-python
[https://pypi.org/project/pygeoip/ pygeoip] as `py3-geoip` which is not
the same as the [https://pypi.org/project/GeoIP/ MaxMind GeoIP]
(`python3-geoip` on Ubuntu).
However they packages are compatible with some minor changes:
{{{#!diff
diff --git deluge/core/preferencesmanager.py
deluge/core/preferencesmanager.py
index e3c935c99..19dd3b2fb 100644
--- deluge/core/preferencesmanager.py
+++ deluge/core/preferencesmanager.py
@@ -24,10 +24,15 @@
from deluge._libtorrent import lt
from deluge.event import ConfigValueChangedEvent
+GeoIP = None
try:
- import GeoIP
+ from GeoIP import GeoIP
except ImportError:
- GeoIP = None
+ try:
+ from pygeoip import GeoIP
+ except:
+ ImportError:
+ pass
try:
from urllib.parse import quote_plus
@@ -464,9 +469,7 @@ def _on_set_geoip_db_location(self, key,
geoipdb_path):
# Load the GeoIP DB for country look-ups if available
if os.path.exists(geoipdb_path):
try:
- self.core.geoip_instance = GeoIP.open(
- geoipdb_path, GeoIP.GEOIP_STANDARD
- )
+ self.core.geoip_instance = GeoIP(geoipdb_path, 0)
except AttributeError:
log.warning('GeoIP Unavailable')
else:
}}}
--
Ticket URL: <https://dev.deluge-torrent.org/ticket/3271>
Deluge <https://deluge-torrent.org/>
Deluge Project
--
You received this message because you are subscribed to the Google Groups
"Deluge Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/deluge-dev.
To view this discussion on the web visit
https://groups.google.com/d/msgid/deluge-dev/042.1ad88fccda0971add0b1bab1725fdccf%40deluge-torrent.org.
For more options, visit https://groups.google.com/d/optout.