[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Add support for listing available nettests.



commit 8ea550135fbca0b90f6811996ce8c905cad5248f
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Wed Nov 27 22:23:28 2013 +0100

    Add support for listing available nettests.
---
 ooni/director.py |    1 +
 ooni/nettest.py  |    2 +-
 ooni/oonicli.py  |   17 ++++++++++++++---
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ooni/director.py b/ooni/director.py
index 7a81815..46dd962 100644
--- a/ooni/director.py
+++ b/ooni/director.py
@@ -106,6 +106,7 @@ class Director(object):
                 if is_nettest(filename):
                     net_test_file = os.path.join(dirname, filename)
                     nettest = getNetTestInformation(net_test_file)
+                    nettest['category'] = category.replace('/', '')
 
                     if nettest['id'] in nettests:
                         log.err("Found a two tests with the same name %s, %s" %
diff --git a/ooni/nettest.py b/ooni/nettest.py
index 7049ad1..b421252 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -166,7 +166,7 @@ def getNetTestInformation(net_test_file):
         'description': test_class.description,
         'version': test_class.version,
         'arguments': getArguments(test_class),
-        'path': net_test_file
+        'path': net_test_file,
     }
     return information
 
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index c722c52..c5e7c53 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -30,7 +30,8 @@ class Options(usage.Options):
 
     optFlags = [["help", "h"],
                 ["resume", "r"],
-                ["no-collector", "n"]
+                ["no-collector", "n"],
+                ["list", "s"],
                 ]
 
     optParameters = [["reportfile", "o", None, "report file name"],
@@ -72,7 +73,7 @@ class Options(usage.Options):
         sys.settrace(spewer)
 
     def parseArgs(self, *args):
-        if self['testdeck']:
+        if self['testdeck'] or self['list']:
             return
         try:
             self['test_file'] = args[0]
@@ -112,7 +113,7 @@ def runWithDirector():
     config.read_config_file()
 
     log.start(global_options['logfile'])
-
+    
     if config.privacy.includepcap:
         try:
             checkForRoot()
@@ -127,6 +128,16 @@ def runWithDirector():
     director = Director()
     d = director.start()
 
+    if global_options['list']:
+        print "# Installed nettests"
+        for net_test_id, net_test in director.netTests.items():
+            print "* %s (%s/%s)" % (net_test['name'],
+                                    net_test['category'], 
+                                    net_test['id'])
+            print "  %s" % net_test['description']
+
+        sys.exit(0)
+
     #XXX: This should mean no bouncer either!
     if global_options['no-collector']:
         log.msg("Not reporting using a collector")



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits