[Pkg-privacy-commits] [tor-monitor] 24/39: Don't fail when the country returned by Tor is wrong

Sascha Steinbiss sascha-guest at moszumanska.debian.org
Tue Aug 25 18:00:45 UTC 2015


This is an automated email from the git hooks/post-receive script.

sascha-guest pushed a commit to branch master
in repository tor-monitor.

commit 25135c53453dadf5ae8b43a68c7b6a6cc5e642d9
Author: Tails developers <tails at boum.org>
Date:   Tue Feb 24 18:57:25 2015 +0100

    Don't fail when the country returned by Tor is wrong
    
    It happens that Tor returns "??" as a country. In case the country
    isnt' known by pycountry, just display the string returned by Tor.
---
 tormonitor | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tormonitor b/tormonitor
index 1fc2a62..82c4bfc 100755
--- a/tormonitor
+++ b/tormonitor
@@ -531,7 +531,12 @@ class TorMonitorWindow(Gtk.ApplicationWindow):
         """
         country = self.controller.get_info("ip-to-country/%s" % status_entry.address)
         if pycountry:
-            country = pycountry.countries.get(alpha2=country.upper()).name
+            try:
+                country = pycountry.countries.get(alpha2=country.upper()).name
+            except KeyError:
+                # If pycountry can't find the country, just display the string
+                # returned by Tor.
+                pass
 
         grid = Gtk.Grid()
         grid.set_property('row-spacing', 6)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/tor-monitor.git



More information about the Pkg-privacy-commits mailing list