[Pkg-privacy-commits] [onioncircuits] 15/39: Cope with a missing geoipdb
Sascha Steinbiss
sascha at steinbiss.name
Sun May 15 16:40:44 UTC 2016
This is an automated email from the git hooks/post-receive script.
sascha-guest pushed a commit to branch master
in repository onioncircuits.
commit 5186768192f9805bcc5b21ea42d388441fecb3ba
Author: Alan <alan at boum.org>
Date: Fri Apr 1 17:18:01 2016 +0000
Cope with a missing geoipdb
Make sure that onioncircuits can still display useful results without
tor-geoipdb installed.
Based on the patch from Sascha Steinbiss <sascha at steinbiss.name>
---
onioncircuits | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/onioncircuits b/onioncircuits
index 2974749..02858cc 100755
--- a/onioncircuits
+++ b/onioncircuits
@@ -65,6 +65,7 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
Gtk.Window.__init__(self, application=app)
self._listeners_initialized = False
+ self._geoip_message_shown = False
self._circ_to_iter = {}
self._stream_to_iter = {}
self.controller = self.get_application().controller
@@ -541,8 +542,18 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
:var stem.descriptor.router_status_entry.RouterStatusEntryMicroV3
status_entry: the status entry for the node
"""
- country = self.controller.get_info("ip-to-country/%s" % status_entry.address)
- if pycountry:
+ try:
+ country = self.controller.get_info("ip-to-country/%s" % status_entry.address)
+ except stem.ProtocolError:
+ country = None
+ if not self._geoip_message_shown:
+ self._infobar_label.set_text(_("GeoIP database unavailable. "
+ "No country information will be displayed."))
+ self._infobar.set_message_type(Gtk.MessageType.WARNING)
+ self._infobar.show()
+ self._geoip_message_shown = True
+
+ if pycountry and country:
try:
country = pycountry.countries.get(alpha2=country.upper()).name
except KeyError:
@@ -550,6 +561,12 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
# returned by Tor.
pass
+ # if we couldn't get a country, just display the IP
+ if country:
+ ip_with_country = _("%s (%s)") % (status_entry.address, country)
+ else:
+ ip_with_country = str(status_entry.address)
+
grid = Gtk.Grid()
grid.set_property('row-spacing', 6)
grid.set_property('column-spacing', 12)
@@ -563,7 +580,7 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
line = 1
for l, v in [(_("Fingerprint:"), status_entry.fingerprint),
(_("Published:"), status_entry.published),
- (_("IP:"), _("%s (%s)") % (status_entry.address, country)),
+ (_("IP:"), ip_with_country),
(_("Bandwidth:"), _("%.2f Mb/s") % (status_entry.bandwidth/1024.)),
]:
label = Gtk.Label(l)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncircuits.git
More information about the Pkg-privacy-commits
mailing list