[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [oonib/master] Implement input API as spec'd in oonib.md
commit b7fd4b9db379fc9bc28f22f6608c804e9f08e181
Author: aagbsn <aagbsn@xxxxxxxx>
Date: Sun Aug 18 23:25:36 2013 +0200
Implement input API as spec'd in oonib.md
---
oonib/input/handlers.py | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/oonib/input/handlers.py b/oonib/input/handlers.py
index 3ab0ea0..8db1482 100644
--- a/oonib/input/handlers.py
+++ b/oonib/input/handlers.py
@@ -1,28 +1,25 @@
import glob
import json
import os
-
import yaml
from oonib.handlers import OONIBHandler
-
-from oonib import config
+from oonib import config, log
class InputDescHandler(OONIBHandler):
def get(self, inputID):
- #XXX return the input descriptor
- # see oonib.md in ooni-spec
bn = os.path.basename(inputID) + ".desc"
try:
f = open(os.path.join(config.main.input_dir, bn))
a = {}
inputDesc = yaml.safe_load(f)
- a['id'] = inputID
- a['name'] = inputDesc['name']
- a['description'] = inputDesc['description']
+ for k in ['name', 'description', 'version', 'author', 'date']:
+ a[k] = inputDesc[k]
self.write(json.dumps(a))
- except Exception:
+ except IOError:
log.err("No Input Descriptor found for id %s" % inputID)
+ except Exception, e:
+ log.err("Invalid Input Descriptor found for id %s" % inputID)
class InputListHandler(OONIBHandler):
def get(self):
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits