Commit 01b84885 authored by Nicolas Wavrant's avatar Nicolas Wavrant

runner: minishell displays current path

parent 1f277080
......@@ -39,7 +39,7 @@ $(document).ready(function () {
var old_shell_btn_background = $(".shell_btn").css("background");
$(".shell_btn").css("background", "url(/static/css/images/loading-min.gif) center right no-repeat")
$.post("/runCommand", data, function (data) {
var data = "<p><span class=\"runned-command\">>>> " + command + "</span></p><br/><pre>" + 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-input").val("");
$("#shell-result").scrollTop($("#shell-result")[0].scrollHeight);
......
......@@ -727,10 +727,10 @@ def runCommand():
# if the command was just cd, execute it. Otherwise, execute the rest
command = command.replace(' '.join(cmd), '').strip(';')
if not command:
return "Changed directory, now in : " + cwd
return jsonify(path=cwd, data="Changed directory, now in : "+cwd)
try:
setMiniShellHistory(app.config, command)
return 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:
error = "Error : process exited with exit code " + str(e.returncode) + \
"\nProcess says :\n" + e.output
......
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