
commit a40c62e1f4e49fbf5949a328f12df9b4e629199a Author: aagbsn <aagbsn@extc.org> Date: Wed Jul 3 10:30:38 2013 +0200 Add Handlers that list Decks and Inputs --- oonib/report/api.py | 2 ++ oonib/report/file_collector.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/oonib/report/api.py b/oonib/report/api.py index 871836b..8835784 100644 --- a/oonib/report/api.py +++ b/oonib/report/api.py @@ -49,6 +49,8 @@ reportingBackendAPI = [ (r"/report/([a-zA-Z0-9_\-]+)/close", file_collector.CloseReportHandlerFile), (r"/report", file_collector.NewReportHandlerFile), (r"/pcap", file_collector.PCAPReportHandler), + (r"/deck", file_collector.DeckListHandler), + (r"/input", file_collector.InputListHandler), (r"/deck/([a-z0-9]{40})$", web.StaticFileHandler, {"path": config.main.deck_dir}), (r"/input/([a-z0-9]{40})$", web.StaticFileHandler, {"path": diff --git a/oonib/report/file_collector.py b/oonib/report/file_collector.py index c8f0a63..57c4175 100644 --- a/oonib/report/file_collector.py +++ b/oonib/report/file_collector.py @@ -287,3 +287,17 @@ class PCAPReportHandler(web.RequestHandler): def post(self): pass + +class DeckListHandler(web.RequestHandler): + def get(self): + if not config.main.deck_dir: return + path = os.path.abspath(config.main.deck_dir) + "/*" + decknames = map(os.path.basename, glob.iglob(path)) + self.write(json.dumps(decknames)) + +class InputListHandler(web.RequestHandler): + def get(self): + if not config.main.input_dir: return + path = os.path.abspath(config.main.input_dir) + "/*" + inputnames = map(os.path.basename, glob.iglob(path)) + self.write(json.dumps(decknames))