[tor-commits] [ooni-probe/master] Improve readability of the ooniprobe -s command

art at torproject.org art at torproject.org
Fri Apr 29 09:42:26 UTC 2016


commit 33e86a4a4ae96053812685c9f663db261703e449
Author: Arturo Filastò <arturo at filasto.net>
Date:   Sun Apr 24 19:13:45 2016 +0200

    Improve readability of the ooniprobe -s command
    
    * Remove various pieces of dead code
---
 data/ooniprobe.conf.sample           |  2 --
 ooni/director.py                     |  2 +-
 ooni/geoip.py                        | 20 --------------------
 ooni/nettests/third_party/psiphon.py |  4 ++--
 ooni/oonicli.py                      | 30 +++++++++++++++++++++++-------
 ooni/tests/test_oonicli.py           |  1 -
 ooni/utils/log.py                    |  2 --
 7 files changed, 26 insertions(+), 35 deletions(-)

diff --git a/data/ooniprobe.conf.sample b/data/ooniprobe.conf.sample
index 5f3f17d..edc3f86 100644
--- a/data/ooniprobe.conf.sample
+++ b/data/ooniprobe.conf.sample
@@ -12,8 +12,6 @@ privacy:
     includeasn: true
     # Should we include the country as reported by GeoIP in the report?
     includecountry: true
-    # Should we include the city as reported by GeoIP in the report?
-    includecity: false
     # Should we collect a full packet capture on the client?
     includepcap: false
 reports:
diff --git a/ooni/director.py b/ooni/director.py
index ab8da65..a60b91e 100644
--- a/ooni/director.py
+++ b/ooni/director.py
@@ -61,7 +61,7 @@ class Director(object):
 
     _scheduledTests = 0
     # Only list NetTests belonging to these categories
-    categories = ['blocking', 'manipulation']
+    categories = ['blocking', 'manipulation', 'third_party']
 
     def __init__(self):
         self.activeNetTests = []
diff --git a/ooni/geoip.py b/ooni/geoip.py
index 6179844..417c7d5 100644
--- a/ooni/geoip.py
+++ b/ooni/geoip.py
@@ -171,8 +171,6 @@ class ProbeIP(object):
         self.geodata['ip'] = self.address
         if not config.privacy.includeasn:
             self.geodata['asn'] = 'AS0'
-        if not config.privacy.includecity:
-            self.geodata['city'] = None
         if not config.privacy.includecountry:
             self.geodata['countrycode'] = 'ZZ'
         if not config.privacy.includeip:
@@ -194,16 +192,6 @@ class ProbeIP(object):
                 log.msg("Unable to lookup the probe IP via Tor.")
 
             try:
-                yield self.askTraceroute()
-                log.msg("Found your IP via Traceroute %s" % self.address)
-                self.resolveGeodata()
-                defer.returnValue(self.address)
-            except errors.InsufficientPrivileges:
-                log.debug("Cannot determine the probe IP address with a traceroute, becase of insufficient priviledges")
-            except:
-                log.msg("Unable to lookup the probe IP via traceroute")
-
-            try:
                 yield self.askGeoIPService()
                 log.msg("Found your IP via a GeoIP service: %s" % self.address)
                 self.resolveGeodata()
@@ -230,14 +218,6 @@ class ProbeIP(object):
         if not self.address:
             raise errors.ProbeIPUnknown
 
-    def askTraceroute(self):
-        """
-        Perform a UDP traceroute to determine the probes IP address.
-        """
-        if not hasRawSocketPermission():
-            raise errors.InsufficientPrivileges
-        raise NotImplemented
-
     def askTor(self):
         """
         Obtain the probes IP address by asking the Tor Control port via GET INFO
diff --git a/ooni/nettests/third_party/psiphon.py b/ooni/nettests/third_party/psiphon.py
index bfdec70..2633f60 100644
--- a/ooni/nettests/third_party/psiphon.py
+++ b/ooni/nettests/third_party/psiphon.py
@@ -30,8 +30,8 @@ class PsiphonTest(httpt.HTTPTest,  process.ProcessTest):
     """
 
     name = "Psiphon Test"
-    description = "Bootstraps Psiphon and \
-                does a HTTP GET for the specified URL"
+    description = ("Bootstraps Psiphon and"
+                   "does a HTTP GET for the specified URL")
     author = "juga"
     version = "0.0.1"
     timeout = 20
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index 8e7d1f1..3be64a9 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -4,6 +4,7 @@ import os
 import json
 import yaml
 import random
+import textwrap
 import urlparse
 
 from twisted.python import usage
@@ -24,7 +25,6 @@ class Options(usage.Options):
                 " files listed on the command line.")
 
     optFlags = [["help", "h"],
-                ["resume", "r"],
                 ["no-collector", "n", "disable writing to collector"],
                 ["no-yamloo", "N", "disable writing to YAML file"],
                 ["no-geoip", "g"],
@@ -342,12 +342,28 @@ def runWithDirector(logging=True, start_tor=True, check_incoherences=True):
     from ooni.director import Director
     director = Director()
     if global_options['list']:
-        print "# Installed nettests"
-        for net_test_id, net_test in director.getNetTests().items():
-            print "* %s (%s/%s)" % (net_test['name'],
-                                    net_test['category'],
-                                    net_test['id'])
-            print "  %s" % net_test['description']
+        net_tests = [net_test for net_test in director.getNetTests().items()]
+        print ""
+        print "Installed nettests"
+        print "=================="
+        for net_test_id, net_test in net_tests:
+            optList = []
+            for name, details in net_test['arguments'].items():
+                optList.append({'long': name, 'doc': details['description']})
+
+            desc = ('\n' +
+                    net_test['name'] +
+                    '\n' +
+                    '-'*len(net_test['name']) +
+                    '\n' +
+                    '\n'.join(textwrap.wrap(net_test['description'], 80)) +
+                    '\n\n' +
+                    '$ ooniprobe {}/{}'.format(net_test['category'],
+                                                      net_test['id']) +
+                    '\n\n' +
+                    ''.join(usage.docMakeChunks(optList))
+            )
+            print desc
 
         sys.exit(0)
 
diff --git a/ooni/tests/test_oonicli.py b/ooni/tests/test_oonicli.py
index c3b179a..172b9cd 100644
--- a/ooni/tests/test_oonicli.py
+++ b/ooni/tests/test_oonicli.py
@@ -33,7 +33,6 @@ privacy:
     includeip: false
     includeasn: true
     includecountry: true
-    includecity: false
     includepcap: true
 reports:
     pcap: null
diff --git a/ooni/utils/log.py b/ooni/utils/log.py
index d3036f0..f36c0ff 100644
--- a/ooni/utils/log.py
+++ b/ooni/utils/log.py
@@ -52,8 +52,6 @@ class OONILogger(object):
     def start(self, logfile=None, application_name="ooniprobe"):
         from ooni.settings import config
 
-        daily_logfile = None
-
         if not logfile:
             logfile = os.path.expanduser(config.basic.logfile)
 





More information about the tor-commits mailing list