From: "Antanas Ursulis" <antanas.ursulis@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/log-analysis:master commit in: /
Date: Fri, 5 Jul 2013 00:00:35 +0000 (UTC) [thread overview]
Message-ID: <1372979924.adecdbc1cd849ca19fbccf2c189f676d54b51e85.uranium@gentoo> (raw)
commit: adecdbc1cd849ca19fbccf2c189f676d54b51e85
Author: Antanas Uršulis <antanas.ursulis <AT> gmail <DOT> com>
AuthorDate: Thu Jul 4 23:18:44 2013 +0000
Commit: Antanas Ursulis <antanas.ursulis <AT> gmail <DOT> com>
CommitDate: Thu Jul 4 23:18:44 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/log-analysis.git;a=commit;h=adecdbc1
Group logs by source hostname and add multiple-file submissions
---
flask_app.py | 11 +++++------
simple_client.py | 15 +++++++++------
submission.proto | 8 ++++++--
3 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/flask_app.py b/flask_app.py
index 87697e5..ce55c38 100644
--- a/flask_app.py
+++ b/flask_app.py
@@ -3,7 +3,7 @@ The web application built on Flask is contained within this file.
When run as a script, the Flask development server is started.
"""
-import os
+import os, socket
import submission_pb2, storage
from flask import Flask, request
@@ -16,13 +16,12 @@ def index():
@app.route('/submit', methods=['POST'])
def submit():
- """
- TODO:
- pass through all steps - input, analysis, storage
- """
submission = submission_pb2.Submission()
submission.ParseFromString(request.data)
- store.save_file(request.remote_addr, submission.filename, submission.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)
return ''
if __name__ == '__main__':
diff --git a/simple_client.py b/simple_client.py
index bbd7835..0335260 100644
--- a/simple_client.py
+++ b/simple_client.py
@@ -4,16 +4,19 @@ Simple submission client that forms a correct protobuf message and performs a PO
import submission_pb2, sys, urllib
-def send_submission(filename):
+def send_submission(filenames):
submission = submission_pb2.Submission()
- submission.filename = filename
- submission.data = open(filename, 'rb').read()
+
+ for f in filenames:
+ new_file = submission.files.add()
+ new_file.filename = f
+ new_file.data = open(f, 'rb').read()
print urllib.urlopen('http://[::1]:5000/submit', submission.SerializeToString()).read()
if __name__ == '__main__':
- if len(sys.argv) != 2:
- sys.stderr.write('usage: ' + sys.argv[0] + ' FILENAME\n')
+ if len(sys.argv) < 2:
+ sys.stderr.write('usage: ' + sys.argv[0] + ' FILENAMES\n')
sys.exit(-1)
- send_submission(sys.argv[1])
+ send_submission(sys.argv[1:])
diff --git a/submission.proto b/submission.proto
index 70a60de..b06310f 100644
--- a/submission.proto
+++ b/submission.proto
@@ -1,4 +1,8 @@
message Submission {
- required string filename = 1;
- required bytes data = 2;
+ message File {
+ required string filename = 1;
+ required bytes data = 2;
+ }
+
+ repeated File files = 1;
}
next reply other threads:[~2013-07-05 0:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-05 0:00 Antanas Ursulis [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-07-29 22:40 [gentoo-commits] proj/log-analysis:master commit in: / Antanas Ursulis
2013-07-29 22:40 Antanas Ursulis
2013-07-29 22:40 Antanas Ursulis
2013-07-29 18:59 Antanas Ursulis
2013-07-29 16:08 Antanas Ursulis
2013-07-29 16:08 Antanas Ursulis
2013-07-29 16:08 Antanas Ursulis
2013-07-29 16:08 Antanas Ursulis
2013-07-05 0:00 Antanas Ursulis
2013-07-04 1:39 Antanas Ursulis
2013-07-03 7:15 Antanas Ursulis
2013-07-03 7:15 Antanas Ursulis
2013-07-03 7:15 Antanas Ursulis
2013-07-03 7:15 Antanas Ursulis
2013-07-03 7:15 Antanas Ursulis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372979924.adecdbc1cd849ca19fbccf2c189f676d54b51e85.uranium@gentoo \
--to=antanas.ursulis@gmail.com \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox