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

[tor-commits] [oonib/master] Add Policy API



commit bf2a444878730722abad43b869a2bb7fe1194579
Author: aagbsn <aagbsn@xxxxxxxx>
Date:   Mon Aug 19 00:00:17 2013 +0200

    Add Policy API
---
 data/policy.yaml         |    2 +-
 oonib/policy/api.py      |    4 ----
 oonib/policy/handlers.py |    8 ++++++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/data/policy.yaml b/data/policy.yaml
index fecdf29..e0d6c08 100644
--- a/data/policy.yaml
+++ b/data/policy.yaml
@@ -1,4 +1,4 @@
-inputs:
+input:
 - {id: 37e60e13536f6afe47a830bfb6b371b5cf65da66d7ad65137344679b24fdccd1}
 - {id: e0611ecd28bead38a7afeb4dda8ae3449d0fc2e1ba53fa7355f2799dce9af290}
 nettest:
diff --git a/oonib/policy/api.py b/oonib/policy/api.py
index 4cacea2..d6fdaad 100644
--- a/oonib/policy/api.py
+++ b/oonib/policy/api.py
@@ -1,10 +1,6 @@
 from oonib.policy import handlers
 
-#XXX: if policy is configured
 policyAPI = [
     (r"/policy/nettest", handlers.NetTestPolicyHandler),
-    #XXX: add nettest handler
-    #(r"/policy/nettest/([a-z0-9]+)/py$", web.StaticFileHandler, {"path":
-    #    config.main.nettest_dir}),
     (r"/policy/input", handlers.InputPolicyHandler),
 ]
diff --git a/oonib/policy/handlers.py b/oonib/policy/handlers.py
index 7544cf9..f72e746 100644
--- a/oonib/policy/handlers.py
+++ b/oonib/policy/handlers.py
@@ -10,11 +10,15 @@ class NetTestPolicyHandler(OONIBHandler):
         """
         returns a list of accepted NetTests
         """
-        pass
+        with open(config.main.policy_file) as f:
+            p = yaml.safe_load(f)
+            self.write(json.dumps(p['nettest']))
 
 class InputPolicyHandler(OONIBHandler):
     def get(self):
         """
         return list of input ids
         """
-        pass
+        with open(config.main.policy_file) as f:
+            p = yaml.safe_load(f)
+            self.write(json.dumps(p['input']))



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