[Pkg-privacy-commits] [onioncircuits] 20/39: Cleanup a bit and pep8-ify onioncircuit

Sascha Steinbiss sascha at steinbiss.name
Sun May 15 16:40:45 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 e3566e28d1775924af4c04d915b6f76581829dd1
Author: Alan <alan at boum.org>
Date:   Sun Apr 3 19:37:20 2016 +0000

    Cleanup a bit and pep8-ify onioncircuit
    
    Will-fix: #11302
    
    Thanks jvoisin for the patch
---
 onioncircuits | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/onioncircuits b/onioncircuits
index c702e72..800384c 100755
--- a/onioncircuits
+++ b/onioncircuits
@@ -16,11 +16,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import datetime
 import gettext
 import logging
 import os
-import socket
 import sys
 
 try:
@@ -47,6 +45,7 @@ if 'DEBUG' in os.environ and os.environ['DEBUG']:
 else:
     logging.getLogger('stem').setLevel(logging.WARNING)
 
+
 class OnionCircuitsWindow(Gtk.ApplicationWindow):
     """Onion Circuits main window
 
@@ -105,7 +104,7 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
 
         self._infobar = Gtk.InfoBar()
         self._infobar.set_no_show_all(True)
-        self._infobar_label = Gtk.Label("");
+        self._infobar_label = Gtk.Label("")
         self._infobar_label.show()
         self._infobar.get_content_area().add(self._infobar_label)
         self._infobar.add_button(_("OK"), Gtk.ResponseType.OK)
@@ -113,12 +112,13 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
         grid.attach(self._infobar, 0, 0, 2, 1)
 
         # Circuits/streams list
-        self._treestore = Gtk.TreeStore(GObject.TYPE_INT,    # TYPE_CIRC or TYPE_STREAM
-                                        GObject.TYPE_STRING, # id
-                                        GObject.TYPE_STRING, # path
-                                        GObject.TYPE_STRING) # status
+        self._treestore = Gtk.TreeStore(GObject.TYPE_INT,     # TYPE_CIRC or TYPE_STREAM
+                                        GObject.TYPE_STRING,  # id
+                                        GObject.TYPE_STRING,  # path
+                                        GObject.TYPE_STRING)  # status
         self._treeview = Gtk.TreeView.new_with_model(self._treestore)
         self._treeview.get_selection().connect('changed', self.cb_treeselection_changed)
+
         def append_column(tv, col, name=None):
             tvcolumn = Gtk.TreeViewColumn(name)
             tv.append_column(tvcolumn)
@@ -304,8 +304,8 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
             # XXX: it may happen that the treeiter is not valid anymore
             # e.g. because it represents a stream that has been remapped
             # to another circuit.
-            logging.warn("cannot remove %s which is not valid" % treeiter)
-        return False # to cancel the repetition when used in timeout_add
+            logging.warning("cannot remove %s which is not valid" % treeiter)
+        return False  # to cancel the repetition when used in timeout_add
 
     # Circuits
     # --------
@@ -417,7 +417,7 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
             return None
         circ_iter = self._circ_to_iter[stream.circ_id]
         if not circ_iter:
-            logging.warn("no iter found for %s" % circ_id)
+            logging.warning("no iter found for %s" % circ_id)
             circ_iter = self.add_circuit(self.controller.get_circuit(circ_id))
         stream_iter = self._treestore.append(circ_iter,
                     [self.TYPE_STREAM,
@@ -479,9 +479,9 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
             self.add_stream(stream_event)
         else:
             self.update_stream(stream_event)
-            if (stream_event.status == stem.StreamStatus.FAILED
-                    or stream_event.status == stem.StreamStatus.CLOSED
-                    or stream_event.status == stem.StreamStatus.DETACHED):
+            if (stream_event.status == stem.StreamStatus.FAILED or
+                    stream_event.status == stem.StreamStatus.CLOSED or
+                    stream_event.status == stem.StreamStatus.DETACHED):
                 self.remove_stream_delayed(stream_event)
 
     def populate_treeview(self):
@@ -514,16 +514,16 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
             self.clear_circuit_details()
             return False
 
-        if model.get_value(selected_iter, 0) == self.TYPE_STREAM: # Stream
+        if model.get_value(selected_iter, 0) == self.TYPE_STREAM:  # Stream
             circuit_iter = model.iter_parent(selected_iter)
-        else: # Circuit
+        else:  # Circuit
             circuit_iter = selected_iter
 
         circ_id = model.get_value(circuit_iter, 1)
         try:
             circuit = self.controller.get_circuit(circ_id)
-        except ValueError as e: # The circuit doesn't exist anymore
-            logging.warn("circuit %s not known by Tor: %s" % (circ_id, e))
+        except ValueError as e:  # The circuit doesn't exist anymore
+            logging.warning("circuit %s not known by Tor: %s" % (circ_id, e))
             return False
         self.show_circuit_details(circuit)
         return False
@@ -589,11 +589,10 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
             country = self.get_country(status_entry.address)
             if country:
                 ip_with_country = _("%s (%s)") % (status_entry.address, country)
-            else: # we couldn't get a country, just display the IP
+            else:  # we couldn't get a country, just display the IP
                 ip_with_country = str(status_entry.address)
 
             published = status_entry.published
-            ip_with_country = _("%s (%s)") % (status_entry.address, country)
             bandwidth = _("%.2f Mb/s") % (status_entry.bandwidth/1024.)
         else:
             published = _("Unknown")
@@ -627,6 +626,7 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
         self._path.add(grid)
         grid.show_all()
 
+
 class OnionCircuitsApplication(Gtk.Application):
     """Onion Circuits application
 

-- 
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