Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.2:Ports
deluge
deluge-libtorrent-1.1-geoip.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File deluge-libtorrent-1.1-geoip.patch of Package deluge
--- a/deluge/core/preferencesmanager.py +++ b/deluge/core/preferencesmanager.py @@ -48,6 +48,11 @@ import deluge.common import deluge.component as component from deluge.log import LOG as log +try: + import GeoIP +except ImportError: + GeoIP = None + DEFAULT_PREFS = { "send_info": False, "info_sent": 0.0, @@ -148,6 +153,7 @@ class PreferencesManager(component.Compo component.Component.__init__(self, "PreferencesManager") self.config = deluge.configmanager.ConfigManager("core.conf", DEFAULT_PREFS) + self.geoip_instance = None def start(self): self.core = component.get("Core") @@ -498,9 +504,13 @@ class PreferencesManager(component.Compo if geoip_db: try: self.session.load_country_db(str(geoip_db)) - except Exception, e: - log.error("Unable to load geoip database!") - log.exception(e) + except (AttributeError, RuntimeError): + try: + self.geoip_instance = GeoIP.open(geoip_db, GeoIP.GEOIP_STANDARD) + except Exception, e: + self.geoip_instance = None + log.error("Unable to load geoip database!") + log.exception(e) def _on_cache_size(self, key, value): log.debug("%s: %s", key, value) --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -554,13 +554,26 @@ class Torrent(object): except UnicodeDecodeError: client = str(peer.client).decode("latin-1") + try: + country = peer.country + except AttributeError: + country = "" + + gi = component.get("PreferencesManager").geoip_instance + if gi: + try: + country = gi.country_code_by_addr(peer.ip[0]) + except: + pass + # Make country a proper string - country = str() - for c in peer.country: + country_tmp = str() + for c in country: if not c.isalpha(): - country += " " + country_tmp += " " else: - country += c + country_tmp += c + country = country_tmp ret.append({ "client": client, --- a/deluge/ui/gtkui/peers_tab.py +++ b/deluge/ui/gtkui/peers_tab.py @@ -262,7 +262,7 @@ class PeersTab(Tab): component.get("SessionProxy").get_torrent_status(torrent_id, ["peers"]).addCallback(self._on_get_torrent_status) def get_flag_pixbuf(self, country): - if country == " ": + if not country.strip(): return None if not self.cached_flag_pixbufs.has_key(country):
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor