summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntanas Uršulis <antanas.ursulis@gmail.com>2013-07-29 19:02:17 +0300
committerAntanas Uršulis <antanas.ursulis@gmail.com>2013-07-29 19:02:17 +0300
commit8dfea24b40c34292f20ab60975d3585094b70cb0 (patch)
treef80a5ff51470fcfc6ac8ff24412efda785ee5582 /flask_app.py
parentPort simple_client to urllib2, so that we can set Content-Type (diff)
downloadlog-analysis-8dfea24b40c34292f20ab60975d3585094b70cb0.tar.gz
log-analysis-8dfea24b40c34292f20ab60975d3585094b70cb0.tar.bz2
log-analysis-8dfea24b40c34292f20ab60975d3585094b70cb0.zip
Introduce processors and PortageProcessor.
A processor is initialised with a database and storage provider. It should implement the process(request, source) method, where request is a protobuf Submission message. process() should analyse the received files, perform any required transformations and should usually store the files and create appropriate database entries. Processors are multiplexed through the 'provider' variable in the protobuf Submission message. This allows to process/analyse various types of logs differently.
Diffstat (limited to 'flask_app.py')
-rw-r--r--flask_app.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/flask_app.py b/flask_app.py
index ce55c38..832702c 100644
--- a/flask_app.py
+++ b/flask_app.py
@@ -7,8 +7,11 @@ import os, socket
import submission_pb2, storage
from flask import Flask, request
+from portage_processor import PortageProcessor
+
app = Flask(__name__)
store = storage.FilesystemStorage('logs/')
+processors = {'portage' : PortageProcessor(None, store)} # TODO: initialise from config file
@app.route('/')
def index():
@@ -19,9 +22,8 @@ def submit():
submission = submission_pb2.Submission()
submission.ParseFromString(request.data)
source = socket.getfqdn(request.remote_addr) # TODO: is this ok?
- # TODO: pass through analyser
- for f in submission.files:
- store.save_file(source, f.filename, f.data)
+
+ processors[submission.provider].process(submission, source)
return ''
if __name__ == '__main__':