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