Loading comm/server/adcclilib.py +12 −3 Changes for comm/server/adcclilib.py: 12 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -7,8 +7,10 @@ ADCCLI = "/home/pi/adc2018/conmgr/client/adccli" def _exec_adccli(cmd): exec_cmd = "{} {} {}".format(PYTHON2, ADCCLI, cmd).strip() print("ADCCLI: {}".format(exec_cmd)) p = subprocess.run(exec_cmd, stdout=subprocess.PIPE, shell=True) res = p.stdout.decode().strip() print(res) return res def login(url, username, password): Loading @@ -35,10 +37,17 @@ def get_q_all(outpath): cmd = "get-q" question_list = _exec_adccli(cmd).split("\n") print("--- ADCCLI questions ---") print(question_list) for v in question_list: out_file_path = "{}/NL_Q{:02d}.txt".format(outpath, int(v)) cmd = "--output {} get-q {}".format(out_file_path, v.rstrip()) _exec_adccli(cmd) if v.startswith("Q"): qnumber = int(v.replace("Q", "")) out_file_path = "{}/NL_Q{:02d}.txt".format(outpath, qnumber) cmd = "--output {} get-q {}".format(out_file_path, qnumber) r = _exec_adccli(cmd) return question_list def put_a(qnum, filepath): cmd = "put-a {} {}".format(qnum, filepath) Loading comm/server/main.py +39 −0 Changes for comm/server/main.py: 39 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -473,6 +473,45 @@ def adccli_whoami(): res = {'message': r, 'status': r == d['username']} return json.dumps(res) @app.route("/adccli-get-all-q") def adccli_get_all_q(): global app_args out_abspath = os.path.abspath(app_args['question']) r = adcclilib.get_q_all(out_abspath) load_questions() res = {'message': r} return json.dumps(res) @app.route("/adccli-put-a", methods=["POST"]) def adccli_put_a(): global app_args global questions qname = request.form["qname"] if not "best_json" in questions[qname]: res = {'message': "Required to 'save' before submission"} else: out_path = "{}/{}".format(app_args['out'], "submit") qnumber = qname.replace("NL_Q", "").replace(".txt", "") ans_file_path = "{}/T01_A{}.txt".format(out_path, qnumber) ans_file_abspath = os.path.abspath(ans_file_path) r = adcclilib.put_a(qnumber, ans_file_abspath) mes = r + "\n" json_name = questions[qname]['best_json'] data = questions[qname]['answers'][json_name] r = adcclilib.put_a_info(qnumber, data['cputime'], "0", "Test") mes += r res = {'message': mes} return json.dumps(res) @app.route("/board-viewer", methods=["GET"]) def show_board_viewer(): Loading comm/server/static/js/pynq-manager.js +20 −12 Changes for comm/server/static/js/pynq-manager.js: 20 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -146,29 +146,26 @@ $(function(){ $("#client-control-pane").html(""); $("#client-control-pane").html(d); $("#adccli-login-button").click(function(){ var $obj = $(this); var button_action_with_ajax = function($obj, url){ $obj.prop("disabled", "disabled"); $.ajax({ type: "GET", url: "/adccli-login", url: url, dataType: "json", }).done((data)=>{ $obj.prop("disabled", false); alert(data['message']); }); }; $("#adccli-login-button").click(function(){ button_action_with_ajax($(this), "/adccli-login"); }); $("#adccli-logout-button").click(function(){ var $obj = $(this); $obj.prop("disabled", "disabled"); $.ajax({ type: "GET", url: "/adccli-logout", dataType: "json", }).done((data)=>{ $obj.prop("disabled", false); alert(data['message']); button_action_with_ajax($(this), "/adccli-logout"); }); $("#adccli-get-all-q").click(function(){ button_action_with_ajax($(this), "/adccli-get-all-q"); }); $.ajax({ Loading Loading @@ -214,6 +211,17 @@ $(function(){ alert(data['status']); }); }); $("#client-control-pane").find(".submit-button").eq(0).click(function(){ var qname = $(this).data("qname"); $.ajax({ type: "POST", dataType: "json", url: "/adccli-put-a", data: {qname: qname} }).done((data) => { alert(data['message']); }); }); $(".answer-detail-row td").click(function(){ var json_name = $(this).parent("tr").data("json"); Loading comm/server/templates/part_client_table.html +2 −0 Changes for comm/server/templates/part_client_table.html: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -13,6 +13,8 @@ Viewer Mode <button type="button" class="btn btn-primary" id="adccli-login-button">Login</button> <button type="button" class="btn btn-light" id="adccli-logout-button">Logout</button> <span id="adccli-status"></span> <br /> <button type="button" class="btn btn-info" id="adccli-get-all-q">問題DL</button> <h4>クライアント</h4> <table class="table table-bordered" id="clients-table"> Loading comm/server/templates/part_question_status.html +4 −1 Changes for comm/server/templates/part_question_status.html: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,8 +3,11 @@ <h3> 【{{qname}}】</h3> <p> <button class="btn btn-primary btn-lg start-button" type="button" data-qname="{{qname}}">Start</button> <button class="btn btn-danger btn-lg stop-button" type="button" data-qname="all">Stop</button><br /> <button class="btn btn-danger btn-lg stop-button" type="button" data-qname="all">Stop</button> </p> <p> <button class="btn btn-info btn-lg save-button" type="button" data-qname="{{qname}}">Save</button> <button class="btn btn-success btn-lg submit-button" type="button" data-qname="{{qname}}">Up</button> </p> </div> <div class="col-8"> Loading Loading
comm/server/adcclilib.py +12 −3 Changes for comm/server/adcclilib.py: 12 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -7,8 +7,10 @@ ADCCLI = "/home/pi/adc2018/conmgr/client/adccli" def _exec_adccli(cmd): exec_cmd = "{} {} {}".format(PYTHON2, ADCCLI, cmd).strip() print("ADCCLI: {}".format(exec_cmd)) p = subprocess.run(exec_cmd, stdout=subprocess.PIPE, shell=True) res = p.stdout.decode().strip() print(res) return res def login(url, username, password): Loading @@ -35,10 +37,17 @@ def get_q_all(outpath): cmd = "get-q" question_list = _exec_adccli(cmd).split("\n") print("--- ADCCLI questions ---") print(question_list) for v in question_list: out_file_path = "{}/NL_Q{:02d}.txt".format(outpath, int(v)) cmd = "--output {} get-q {}".format(out_file_path, v.rstrip()) _exec_adccli(cmd) if v.startswith("Q"): qnumber = int(v.replace("Q", "")) out_file_path = "{}/NL_Q{:02d}.txt".format(outpath, qnumber) cmd = "--output {} get-q {}".format(out_file_path, qnumber) r = _exec_adccli(cmd) return question_list def put_a(qnum, filepath): cmd = "put-a {} {}".format(qnum, filepath) Loading
comm/server/main.py +39 −0 Changes for comm/server/main.py: 39 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -473,6 +473,45 @@ def adccli_whoami(): res = {'message': r, 'status': r == d['username']} return json.dumps(res) @app.route("/adccli-get-all-q") def adccli_get_all_q(): global app_args out_abspath = os.path.abspath(app_args['question']) r = adcclilib.get_q_all(out_abspath) load_questions() res = {'message': r} return json.dumps(res) @app.route("/adccli-put-a", methods=["POST"]) def adccli_put_a(): global app_args global questions qname = request.form["qname"] if not "best_json" in questions[qname]: res = {'message': "Required to 'save' before submission"} else: out_path = "{}/{}".format(app_args['out'], "submit") qnumber = qname.replace("NL_Q", "").replace(".txt", "") ans_file_path = "{}/T01_A{}.txt".format(out_path, qnumber) ans_file_abspath = os.path.abspath(ans_file_path) r = adcclilib.put_a(qnumber, ans_file_abspath) mes = r + "\n" json_name = questions[qname]['best_json'] data = questions[qname]['answers'][json_name] r = adcclilib.put_a_info(qnumber, data['cputime'], "0", "Test") mes += r res = {'message': mes} return json.dumps(res) @app.route("/board-viewer", methods=["GET"]) def show_board_viewer(): Loading
comm/server/static/js/pynq-manager.js +20 −12 Changes for comm/server/static/js/pynq-manager.js: 20 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -146,29 +146,26 @@ $(function(){ $("#client-control-pane").html(""); $("#client-control-pane").html(d); $("#adccli-login-button").click(function(){ var $obj = $(this); var button_action_with_ajax = function($obj, url){ $obj.prop("disabled", "disabled"); $.ajax({ type: "GET", url: "/adccli-login", url: url, dataType: "json", }).done((data)=>{ $obj.prop("disabled", false); alert(data['message']); }); }; $("#adccli-login-button").click(function(){ button_action_with_ajax($(this), "/adccli-login"); }); $("#adccli-logout-button").click(function(){ var $obj = $(this); $obj.prop("disabled", "disabled"); $.ajax({ type: "GET", url: "/adccli-logout", dataType: "json", }).done((data)=>{ $obj.prop("disabled", false); alert(data['message']); button_action_with_ajax($(this), "/adccli-logout"); }); $("#adccli-get-all-q").click(function(){ button_action_with_ajax($(this), "/adccli-get-all-q"); }); $.ajax({ Loading Loading @@ -214,6 +211,17 @@ $(function(){ alert(data['status']); }); }); $("#client-control-pane").find(".submit-button").eq(0).click(function(){ var qname = $(this).data("qname"); $.ajax({ type: "POST", dataType: "json", url: "/adccli-put-a", data: {qname: qname} }).done((data) => { alert(data['message']); }); }); $(".answer-detail-row td").click(function(){ var json_name = $(this).parent("tr").data("json"); Loading
comm/server/templates/part_client_table.html +2 −0 Changes for comm/server/templates/part_client_table.html: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -13,6 +13,8 @@ Viewer Mode <button type="button" class="btn btn-primary" id="adccli-login-button">Login</button> <button type="button" class="btn btn-light" id="adccli-logout-button">Logout</button> <span id="adccli-status"></span> <br /> <button type="button" class="btn btn-info" id="adccli-get-all-q">問題DL</button> <h4>クライアント</h4> <table class="table table-bordered" id="clients-table"> Loading
comm/server/templates/part_question_status.html +4 −1 Changes for comm/server/templates/part_question_status.html: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,8 +3,11 @@ <h3> 【{{qname}}】</h3> <p> <button class="btn btn-primary btn-lg start-button" type="button" data-qname="{{qname}}">Start</button> <button class="btn btn-danger btn-lg stop-button" type="button" data-qname="all">Stop</button><br /> <button class="btn btn-danger btn-lg stop-button" type="button" data-qname="all">Stop</button> </p> <p> <button class="btn btn-info btn-lg save-button" type="button" data-qname="{{qname}}">Save</button> <button class="btn btn-success btn-lg submit-button" type="button" data-qname="{{qname}}">Up</button> </p> </div> <div class="col-8"> Loading