commit 76767e09cba5dcf3cb19263032331d41046665a0 Author: Arturo Filastò art@baculo.org Date: Wed Jun 13 19:26:17 2012 +0200
Show usage of utilty library with simple HTTP test --- ooni/plugins/httpt.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/ooni/plugins/httpt.py b/ooni/plugins/httpt.py new file mode 100644 index 0000000..3f92019 --- /dev/null +++ b/ooni/plugins/httpt.py @@ -0,0 +1,40 @@ +""" +This is a self genrated test created by scaffolding.py. +you will need to fill it up with all your necessities. +Safe hacking :). +""" +from zope.interface import implements +from twisted.python import usage +from twisted.plugin import IPlugin +from ooni.plugoo.tests import ITest, OONITest +from ooni.plugoo.assets import Asset +from ooni.protocols import http +from ooni import log + +class httptArgs(usage.Options): + optParameters = [['urls', 'u', None, 'Urls file'], + ['resume', 'r', 0, 'Resume at this index']] + +class httptTest(http.HTTPTest): + implements(IPlugin, ITest) + + shortName = "httpt" + description = "httpt" + requirements = None + options = httptArgs + blocking = False + + def control(self, experiment_result, args): + # What you return here ends up inside of the report. + log.msg("Running control") + return {} + + def load_assets(self): + if self.local_options: + return {'url': Asset(self.local_options['urls'])} + else: + return {} + +# We need to instantiate it otherwise getPlugins does not detect it +# XXX Find a way to load plugins without instantiating them. +httpt = httptTest(None, None, None)
tor-commits@lists.torproject.org