[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Fix some issues with ooni.deck
commit d66091573872b8451686d5e61a098145835b2b4b
Author: aagbsn <aagbsn@xxxxxxxx>
Date: Sun Aug 25 20:12:37 2013 +0200
Fix some issues with ooni.deck
1. Do not require a bouncer to use a deck
2. If a bouncer is used, also fetch collectors for tests that
do not list helpers or already have helpers specified in the deck.
---
ooni/deck.py | 25 ++++++++++++++-----------
ooni/oonicli.py | 6 +++++-
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/ooni/deck.py b/ooni/deck.py
index 81b2afa..a8aee39 100644
--- a/ooni/deck.py
+++ b/ooni/deck.py
@@ -14,8 +14,8 @@ import re
import yaml
class Deck(object):
- def __init__(self, bouncer, deckFile=None):
- self.bouncer = bouncer
+ def __init__(self, deckFile=None):
+ self.bouncer = None
self.netTestLoaders = []
self.inputs = []
self.testHelpers = {}
@@ -40,27 +40,30 @@ class Deck(object):
@defer.inlineCallbacks
def setup(self):
""" fetch and verify inputs for all NetTests in the deck """
- for net_test_loader in self.netTestLoaders:
- yield self.fetchAndVerifyNetTestInput(net_test_loader)
- yield self.lookupTestHelper(net_test_loader)
- yield self.lookupTestCollector(net_test_loader)
+ if self.bouncer:
+ for net_test_loader in self.netTestLoaders:
+ yield self.fetchAndVerifyNetTestInput(net_test_loader)
+ yield self.lookupTestHelper(net_test_loader)
+ yield self.lookupTestCollector(net_test_loader)
@defer.inlineCallbacks
def lookupTestHelper(self, net_test_loader):
oonibclient = OONIBClient(self.bouncer)
for th in net_test_loader.requiredTestHelpers:
# {'name':'', 'option':'', 'test_class':''}
- helper = yield oonibclient.lookupTestHelper(th['name'])
- th['test_class'].localOptions[th['option']] = helper['test-helper']
+ response = yield oonibclient.lookupTestHelper(th['name'])
+ th['test_class'].localOptions[th['option']] = response['test-helper']
#XXX: collector is only set once!
- net_test_loader.collector = helper['collector']
-
+ if 'collector' in response.keys():
+ net_test_loader.collector = response['collector'].encode('utf-8')
@defer.inlineCallbacks
def lookupTestCollector(self, net_test_loader):
oonibclient = OONIBClient(self.bouncer)
if net_test_loader.collector is None:
- net_test_loader.collector = oonibclient.lookupTestCollector(th['test_class'].testName)
+ response = yield oonibclient.lookupTestCollector(net_test_loader.testName)
+ if 'collector' in response.keys():
+ net_test_loader.collector = response['collector'].encode('utf-8')
@defer.inlineCallbacks
def fetchAndVerifyNetTestInput(self, net_test_loader):
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index cf7d34d..fb333c7 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -127,10 +127,14 @@ def runWithDirector():
director = Director()
d = director.start()
- deck = Deck(global_options['bouncer'])
+ #XXX: This should mean no bouncer either!
if global_options['no-collector']:
log.msg("Not reporting using a collector")
collector = global_options['collector'] = None
+ global_options['bouncer'] = None
+
+ deck = Deck()
+ deck.bouncer = global_options['bouncer']
try:
if global_options['testdeck']:
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits