Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2018-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
adc2018
adc2018-system
Commits
7dcb3457
Commit
7dcb3457
authored
Aug 16, 2018
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for downloading answers and uploading solutions via adccli (#14)
parent
e3011371
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
17 deletions
+78
-17
adcclilib.py
comm/server/adcclilib.py
+12
-3
main.py
comm/server/main.py
+39
-0
pynq-manager.js
comm/server/static/js/pynq-manager.js
+21
-13
part_client_table.html
comm/server/templates/part_client_table.html
+2
-0
part_question_status.html
comm/server/templates/part_question_status.html
+4
-1
No files found.
comm/server/adcclilib.py
View file @
7dcb3457
...
@@ -7,8 +7,10 @@ ADCCLI = "/home/pi/adc2018/conmgr/client/adccli"
...
@@ -7,8 +7,10 @@ ADCCLI = "/home/pi/adc2018/conmgr/client/adccli"
def
_exec_adccli
(
cmd
):
def
_exec_adccli
(
cmd
):
exec_cmd
=
"{} {} {}"
.
format
(
PYTHON2
,
ADCCLI
,
cmd
)
.
strip
()
exec_cmd
=
"{} {} {}"
.
format
(
PYTHON2
,
ADCCLI
,
cmd
)
.
strip
()
print
(
"ADCCLI: {}"
.
format
(
exec_cmd
))
p
=
subprocess
.
run
(
exec_cmd
,
stdout
=
subprocess
.
PIPE
,
shell
=
True
)
p
=
subprocess
.
run
(
exec_cmd
,
stdout
=
subprocess
.
PIPE
,
shell
=
True
)
res
=
p
.
stdout
.
decode
()
.
strip
()
res
=
p
.
stdout
.
decode
()
.
strip
()
print
(
res
)
return
res
return
res
def
login
(
url
,
username
,
password
):
def
login
(
url
,
username
,
password
):
...
@@ -35,10 +37,17 @@ def get_q_all(outpath):
...
@@ -35,10 +37,17 @@ def get_q_all(outpath):
cmd
=
"get-q"
cmd
=
"get-q"
question_list
=
_exec_adccli
(
cmd
)
.
split
(
"
\n
"
)
question_list
=
_exec_adccli
(
cmd
)
.
split
(
"
\n
"
)
print
(
"--- ADCCLI questions ---"
)
print
(
question_list
)
for
v
in
question_list
:
for
v
in
question_list
:
out_file_path
=
"{}/NL_Q{:02d}.txt"
.
format
(
outpath
,
int
(
v
))
if
v
.
startswith
(
"Q"
):
cmd
=
"--output {} get-q {}"
.
format
(
out_file_path
,
v
.
rstrip
())
qnumber
=
int
(
v
.
replace
(
"Q"
,
""
))
_exec_adccli
(
cmd
)
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
):
def
put_a
(
qnum
,
filepath
):
cmd
=
"put-a {} {}"
.
format
(
qnum
,
filepath
)
cmd
=
"put-a {} {}"
.
format
(
qnum
,
filepath
)
...
...
comm/server/main.py
View file @
7dcb3457
...
@@ -473,6 +473,45 @@ def adccli_whoami():
...
@@ -473,6 +473,45 @@ def adccli_whoami():
res
=
{
'message'
:
r
,
'status'
:
r
==
d
[
'username'
]}
res
=
{
'message'
:
r
,
'status'
:
r
==
d
[
'username'
]}
return
json
.
dumps
(
res
)
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"
])
@
app
.
route
(
"/board-viewer"
,
methods
=
[
"GET"
])
def
show_board_viewer
():
def
show_board_viewer
():
...
...
comm/server/static/js/pynq-manager.js
View file @
7dcb3457
...
@@ -146,29 +146,26 @@ $(function(){
...
@@ -146,29 +146,26 @@ $(function(){
$
(
"#client-control-pane"
).
html
(
""
);
$
(
"#client-control-pane"
).
html
(
""
);
$
(
"#client-control-pane"
).
html
(
d
);
$
(
"#client-control-pane"
).
html
(
d
);
$
(
"#adccli-login-button"
).
click
(
function
(){
var
button_action_with_ajax
=
function
(
$obj
,
url
){
var
$obj
=
$
(
this
);
$obj
.
prop
(
"disabled"
,
"disabled"
);
$obj
.
prop
(
"disabled"
,
"disabled"
);
$
.
ajax
({
$
.
ajax
({
type
:
"GET"
,
type
:
"GET"
,
url
:
"/adccli-login"
,
url
:
url
,
dataType
:
"json"
,
dataType
:
"json"
,
}).
done
((
data
)
=>
{
}).
done
((
data
)
=>
{
$obj
.
prop
(
"disabled"
,
false
);
$obj
.
prop
(
"disabled"
,
false
);
alert
(
data
[
'message'
]);
alert
(
data
[
'message'
]);
});
});
};
$
(
"#adccli-login-button"
).
click
(
function
(){
button_action_with_ajax
(
$
(
this
),
"/adccli-login"
);
});
});
$
(
"#adccli-logout-button"
).
click
(
function
(){
$
(
"#adccli-logout-button"
).
click
(
function
(){
var
$obj
=
$
(
this
);
button_action_with_ajax
(
$
(
this
),
"/adccli-logout"
);
$obj
.
prop
(
"disabled"
,
"disabled"
);
});
$
.
ajax
({
$
(
"#adccli-get-all-q"
).
click
(
function
(){
type
:
"GET"
,
button_action_with_ajax
(
$
(
this
),
"/adccli-get-all-q"
);
url
:
"/adccli-logout"
,
dataType
:
"json"
,
}).
done
((
data
)
=>
{
$obj
.
prop
(
"disabled"
,
false
);
alert
(
data
[
'message'
]);
});
});
});
$
.
ajax
({
$
.
ajax
({
...
@@ -214,6 +211,17 @@ $(function(){
...
@@ -214,6 +211,17 @@ $(function(){
alert
(
data
[
'status'
]);
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
(){
$
(
".answer-detail-row td"
).
click
(
function
(){
var
json_name
=
$
(
this
).
parent
(
"tr"
).
data
(
"json"
);
var
json_name
=
$
(
this
).
parent
(
"tr"
).
data
(
"json"
);
...
...
comm/server/templates/part_client_table.html
View file @
7dcb3457
...
@@ -13,6 +13,8 @@ Viewer Mode
...
@@ -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-primary"
id=
"adccli-login-button"
>
Login
</button>
<button
type=
"button"
class=
"btn btn-light"
id=
"adccli-logout-button"
>
Logout
</button>
<button
type=
"button"
class=
"btn btn-light"
id=
"adccli-logout-button"
>
Logout
</button>
<span
id=
"adccli-status"
></span>
<span
id=
"adccli-status"
></span>
<br
/>
<button
type=
"button"
class=
"btn btn-info"
id=
"adccli-get-all-q"
>
問題DL
</button>
<h4>
クライアント
</h4>
<h4>
クライアント
</h4>
<table
class=
"table table-bordered"
id=
"clients-table"
>
<table
class=
"table table-bordered"
id=
"clients-table"
>
...
...
comm/server/templates/part_question_status.html
View file @
7dcb3457
...
@@ -3,8 +3,11 @@
...
@@ -3,8 +3,11 @@
<h3>
【{{qname}}】
</h3>
<h3>
【{{qname}}】
</h3>
<p>
<p>
<button
class=
"btn btn-primary btn-lg start-button"
type=
"button"
data-qname=
"{{qname}}"
>
Start
</button>
<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-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>
</p>
</div>
</div>
<div
class=
"col-8"
>
<div
class=
"col-8"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment