[llvm-commits] [zorg] r130223 - in /zorg/trunk/lnt/lnt: server/ui/templates/submit_run.html server/ui/views.py util/ImportData.py
Daniel Dunbar
daniel at zuster.org
Tue Apr 26 10:48:33 PDT 2011
Author: ddunbar
Date: Tue Apr 26 12:48:33 2011
New Revision: 130223
URL: http://llvm.org/viewvc/llvm-project?rev=130223&view=rev
Log:
LNT/Flask: Port submit page.
Added:
zorg/trunk/lnt/lnt/server/ui/templates/submit_run.html
Modified:
zorg/trunk/lnt/lnt/server/ui/views.py
zorg/trunk/lnt/lnt/util/ImportData.py
Added: zorg/trunk/lnt/lnt/server/ui/templates/submit_run.html
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/submit_run.html?rev=130223&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/templates/submit_run.html (added)
+++ zorg/trunk/lnt/lnt/server/ui/templates/submit_run.html Tue Apr 26 12:48:33 2011
@@ -0,0 +1,26 @@
+{% extends "layout.html" %}
+{% set components = [] %}
+{% block title %}Submit Run{% endblock %}
+{% block body %}
+
+{% if error %}
+ <p><font color="#FF0000">{{ error }}</font></p>
+{% endif %}
+
+<form method="post" enctype="multipart/form-data" action="">
+<b>Input File (plist):</b><br>
+<input type="file" name="file"><br>
+
+<p><b>Input Data (plist):</b><br>
+<textarea name="input_data"></textarea>
+
+<p><b>Commit*:</b><br>
+<select name="commit">
+<option selected="selected" value="0">0</option>
+<option value="1">1</option>
+</select><br>
+
+<p><input type="submit" name="submit" value="Submit">
+</form>
+
+{% endblock %}
Modified: zorg/trunk/lnt/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130223&r1=130222&r2=130223&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/views.py (original)
+++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:48:33 2011
@@ -1,4 +1,6 @@
import os
+import tempfile
+import time
import flask
from flask import abort
@@ -79,9 +81,48 @@
def browse():
return render_template("browse.html")
- at db_route('/submitRun')
+ at db_route('/submitRun', methods=('GET', 'POST'))
def submit_run():
- raise NotImplementedError
+ from lnt.util import ImportData
+
+ if request.method == 'POST':
+ input_file = request.files.get('file')
+ input_data = request.form.get('input_data')
+ commit = int(request.form.get('commit', 0))
+
+ if not input_file.content_length and not input_data:
+ return render_template(
+ "submit_run.html", error="must provide input file or data")
+ if input_file.content_length and input_data:
+ return render_template(
+ "submit_run.html", error="cannot provide input file *and* data")
+
+ if input_file.content_length:
+ data_value = input_file.read()
+ else:
+ data_value = input_data
+
+ # Stash a copy of the raw submission.
+ prefix = time.strftime("data-%Y-%m-%d_%H-%M-%S")
+ fd,path = tempfile.mkstemp(prefix=prefix,
+ suffix='.plist',
+ dir=current_app.old_config.tempDir)
+ os.write(fd, data_value)
+ os.close(fd)
+
+ # Get a DB connection.
+ db = request.get_db()
+
+ # Import the data.
+ #
+ # FIXME: Gracefully handle formats failures and DOS attempts. We
+ # should at least reject overly large inputs.
+ result = ImportData.import_and_report(
+ current_app.old_config, g.db_name, db, path, '<auto>', commit)
+
+ return flask.jsonify(data = result)
+
+ return render_template("submit_run.html")
###
# Generic Database Views
Modified: zorg/trunk/lnt/lnt/util/ImportData.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ImportData.py?rev=130223&r1=130222&r2=130223&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/util/ImportData.py (original)
+++ zorg/trunk/lnt/lnt/util/ImportData.py Tue Apr 26 12:48:33 2011
@@ -60,7 +60,7 @@
importStartTime = time.time()
try:
- success,run = perfdb.importDataFromDict(db, data)
+ success,run = lnt.db.perfdb.importDataFromDict(db, data)
except KeyboardInterrupt:
raise
except:
More information about the llvm-commits
mailing list