def submit(): data = request.data response = {"success": False} command = request.form.get("input") entry_check = {"success": False} result_check = {"success": False} if "progress" not in session: session["progress"] = Progress() if command: progress = session["progress"] entry_check = progress.check_entry(command) if entry_check["continue"]: try: result = command_execute.execute(command) except CommandException, error: response["error"] = "Error: %s" %error else: response = {"success": True, "result": result} result_check = progress.check_result(result) else: response = {"success": True, "result": ""}
def test_valid_execute(self): execute("cat /home/divineslayer/dog") execute('sed "s/cat/bird/g" dog') execute('sed -e "s/cat/bird/g" dog') assert execute('cat dog | sed "s/cat/bird/g"').strip() == "birds and dogs until the end of time"
def test_execeute_error(self): with pytest.raises(RunError): execute("cat nox")