Description: make onioncircuits more robust wrt missing geoipdb
 This patch makes sure that onioncircuits can still display useful
 results without tor-geoipdb installed.
Author: Sascha Steinbiss <sascha@steinbiss.name>
Forwarded: via email
Last-Update: 2016-03-08 
--- a/onioncircuits
+++ b/onioncircuits
@@ -65,6 +65,7 @@
         Gtk.Window.__init__(self, application=app)
 
         self._listeners_initialized = False
+        self._geoip_msg_shown = False
         self._circ_to_iter = {}
         self._stream_to_iter = {}
         self.controller = self.get_application().controller
@@ -541,8 +542,18 @@
         :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_msg_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_msg_shown = True
+
+        if pycountry and country:
             try:
                 country = pycountry.countries.get(alpha2=country.upper()).name
             except KeyError:
@@ -560,10 +571,16 @@
         title.set_halign(Gtk.Align.START)
         grid.attach(title, 0, 0, 2, 1)
 
+        # if we couldn't get a country, just display the IP
+        if not country:
+            ipstr = str(status_entry.address)
+        else:
+            ipstr = _("%s (%s)") % (status_entry.address, country)
+
         line = 1
         for l, v in [(_("Fingerprint:"), status_entry.fingerprint),
                      (_("Published:"), status_entry.published),
-                     (_("IP:"), _("%s (%s)") % (status_entry.address, country)),
+                     (_("IP:"), ipstr),
                      (_("Bandwidth:"), _("%.2f Mb/s") % (status_entry.bandwidth/1024.)),
                     ]:
             label = Gtk.Label(l)
--- a/po/fr.po
+++ b/po/fr.po
@@ -7,85 +7,93 @@
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-08-17 20:57+0000\n"
-"PO-Revision-Date: 2015-08-17 21:05-0000\n"
+"POT-Creation-Date: 2016-03-09 00:24+0000\n"
+"PO-Revision-Date: 2016-03-09 00:24+0000\n"
 "Last-Translator: Tails Developers <tails@boum.org>\n"
 "Language-Team: Tails Developers <tails@boum.org>\n"
+"Language: fr\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 1.5.4\n"
+"X-Generator: Poedit 1.8.7.1\n"
 
-#: ../onioncircuits:77
-msgid "Cannot connect to the Tor daemon. Onion Circuits will try to reconnect..."
+#: ../onioncircuits:82
+msgid ""
+"Cannot connect to the Tor daemon. Onion Circuits will try to reconnect..."
 msgstr ""
 "Impossible de se connecter au démon Tor. Onion Circuits va essayer de se "
 "reconnecter..."
 
-#: ../onioncircuits:90
+#: ../onioncircuits:95
 msgid "Onion Circuits"
 msgstr "Onion Circuits"
 
-#: ../onioncircuits:91
+#: ../onioncircuits:96
 msgid "Display Tor circuits and streams"
 msgstr "Affiche les circuits et les flux de Tor"
 
-#: ../onioncircuits:104
+#: ../onioncircuits:108
 msgid "OK"
 msgstr "OK"
 
-#: ../onioncircuits:121
+#: ../onioncircuits:125
 msgid "Path"
 msgstr "Chemin"
 
-#: ../onioncircuits:122
+#: ../onioncircuits:126
 msgid "Status"
 msgstr "Statut"
 
-#: ../onioncircuits:135
+#: ../onioncircuits:142
 msgid "Click on a path to get details"
 msgstr "Cliquez sur un chemin pour obtenir des détails"
 
-#: ../onioncircuits:209
-msgid "Lost connection to the Tor daemon. Onion Circuits will try to reconnect..."
+#: ../onioncircuits:216
+msgid ""
+"Lost connection to the Tor daemon. Onion Circuits will try to reconnect..."
 msgstr ""
 "Connexion au démon Tor perdue. Onion Circuits va essayer de se reconnecter..."
 
-#: ../onioncircuits:226
+#: ../onioncircuits:233
 msgid "Connected to the Tor daemon! You can use now Onion Circuits."
 msgstr "Connecté au démon Tor. Vous pouvez maintenant utiliser Onion Circuits."
 
-#: ../onioncircuits:308
+#: ../onioncircuits:315
 msgid "Building..."
 msgstr "En construction..."
 
-#: ../onioncircuits:333
+#: ../onioncircuits:340
 #, c-format
 msgid "%s: %s"
 msgstr "%s : %s"
 
-#: ../onioncircuits:552
+#: ../onioncircuits:550
+msgid "GeoIP database unavailable. No country information will be displayed."
+msgstr ""
+"Information GeoIP indisponible. Aucune information de pays sera affiché."
+
+#: ../onioncircuits:578
+#, c-format
+msgid "%s (%s)"
+msgstr "%s (%s)"
+
+#: ../onioncircuits:581
 msgid "Fingerprint:"
 msgstr "Empreinte :"
 
-#: ../onioncircuits:553
+#: ../onioncircuits:582
 msgid "Published:"
 msgstr "Publié :"
 
-#: ../onioncircuits:554
+#: ../onioncircuits:583
 msgid "IP:"
 msgstr "IP :"
 
-#: ../onioncircuits:554
-#, c-format
-msgid "%s (%s)"
-msgstr "%s (%s)"
-
-#: ../onioncircuits:555
+#: ../onioncircuits:584
 msgid "Bandwidth:"
 msgstr "Bande passante :"
 
-#: ../onioncircuits:555
+#: ../onioncircuits:584
 #, c-format
 msgid "%.2f Mb/s"
 msgstr "%2f Mo/s"
