Commit 9764ac1f authored by Nicolas Wavrant's avatar Nicolas Wavrant

try to implement the link verb in slapos.buildout

parent 20d085dc
......@@ -100,14 +100,15 @@ $(document).ready(function () {
$("#flash").fadeOut('normal');
$("#flash").empty();
$("#flash").fadeIn('normal');
if ($("input#path").val() === "") {
var choice = $("input#path").val() || $("input#url").val();
if (choice === "") {
$("#error").Popup("Select a valid Software Release folder!", {type: 'alert', duration: 3000});
return false;
}
$.ajax({
type: "POST",
url: $SCRIPT_ROOT + '/setCurrentProject',
data: "path=" + $("input#path").val(),
data: "path=" + choice,
success: function (data) {
if (data.code === 1) {
window.location.href = $SCRIPT_ROOT + '/editSoftwareProfile';
......
......@@ -28,7 +28,10 @@
</div>
{% elif method == "open" %}
<div id="openSoftware">
<h2 class="hight">Select the folder of your software release into the box</h2>
<h2 class="hight">Enter a URL</h2>
<input type="text" name="path" id="url" value="" />
<h2 class="hight">Or Select the folder of your software release into the box</h2>
<div class='space'></div>
<div id="fileTree" class="file_tree"></div>
<div id="file_info" class="file_info">
......
......@@ -29,9 +29,7 @@ from passlib.apache import HtpasswdFile
import slapos.slap
from slapos.grid.utils import md5digest
# Setup default flask (werkzeug) parser
logger = logging.getLogger('werkzeug')
logger = logging.getLogger('slaprunner')
TRUE_VALUES = (1, '1', True, 'true', 'True')
......@@ -794,6 +792,7 @@ def realpath(config, path, check_exist=True):
this file.
"""
_isurl = re.compile('([a-zA-Z0-9+.-]+)://').match
logger.info('Nicolas : path %s is url ? %s' % (path, _isurl(path)))
if _isurl(path):
return path
split_path = path.split('/')
......
......@@ -18,6 +18,7 @@ import slapos
from slapos.runner.utils import (checkSoftwareFolder, configNewSR, checkUserCredential,
createNewUser, getBuildAndRunParams,
getProfilePath, getSlapgridResult,
html_escape,
listFolder, getBuildAndRunParams,
getProjectTitle, getRcode, updateUserCredential,
getSlapStatus, getSvcStatus,
......@@ -44,10 +45,8 @@ app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = 20 * 1024 * 1024
file_request = FileBrowser(app.config)
# Setup default flask (werkzeug) parser
import logging
logger = logging.getLogger('werkzeug')
logger = logging.getLogger('slaprunner')
def login_redirect(*args, **kwargs):
return redirect(url_for('login'))
......@@ -244,14 +243,13 @@ def getFileLog():
if not os.path.exists(file_path):
raise IOError
if not isText(file_path):
return jsonify(code=0,
result="Can not open binary file, please select a text file!")
content = "Can not open binary file, please select a text file!"
if 'truncate' in request.form:
content = tail(open(file_path), int(request.form['truncate']))
return jsonify(code=1, result=content)
else:
with open(file_path) as f:
return jsonify(code=1, result=f.read())
content = f.read()
return jsonify(code=1, result=html_escape(content))
except:
return jsonify(code=0, result="Warning: Log file doesn't exist yet or empty log!!")
......@@ -304,6 +302,7 @@ def checkFolder():
def setCurrentProject():
logger.info('NICOLAS: setCurrentProject for %s' % request.form['path'])
if configNewSR(app.config, request.form['path']):
session['title'] = getProjectTitle(app.config)
return jsonify(code=1, result="")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment