Commit c2f048cc authored by Nicolas Wavrant's avatar Nicolas Wavrant

runner: adds timeout for command runned in minishell

parent 58877976
...@@ -38,7 +38,13 @@ $(document).ready(function () { ...@@ -38,7 +38,13 @@ $(document).ready(function () {
var data = { command: command }; var data = { command: command };
var old_shell_btn_background = $(".shell_btn").css("background"); var old_shell_btn_background = $(".shell_btn").css("background");
$(".shell_btn").css("background", "url(/static/css/images/loading-min.gif) center right no-repeat") $(".shell_btn").css("background", "url(/static/css/images/loading-min.gif) center right no-repeat")
$.post("/runCommand", data, function (data) { $.ajax({
type: "POST",
url: $SCRIPT_ROOT + "/runCommand",
data: data,
timeout: 600000
})
.done( function (data) {
var data = "<p><span class=\"runned-command\">" + data.path + " >>> " + command + "</span></p><br/><pre>" + data.data + "</pre><br/>"; var data = "<p><span class=\"runned-command\">" + data.path + " >>> " + command + "</span></p><br/><pre>" + data.data + "</pre><br/>";
$("#shell-result").append(data); $("#shell-result").append(data);
$("#shell-input").val(""); $("#shell-input").val("");
......
...@@ -730,6 +730,7 @@ def runCommand(): ...@@ -730,6 +730,7 @@ def runCommand():
return jsonify(path=cwd, data="Changed directory, now in : "+cwd) return jsonify(path=cwd, data="Changed directory, now in : "+cwd)
try: try:
setMiniShellHistory(app.config, command) setMiniShellHistory(app.config, command)
command = "timeout 600 " + command
return jsonify(path=cwd, data=subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True, cwd=cwd)) return jsonify(path=cwd, data=subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True, cwd=cwd))
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
error = "Error : process exited with exit code " + str(e.returncode) + \ error = "Error : process exited with exit code " + str(e.returncode) + \
......
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