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
98831a73
Commit
98831a73
authored
Aug 27, 2018
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'comm-server' into comm
parents
ed903e2f
1f74c9c0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
18 deletions
+24
-18
.gitkeep
answers/submit/.gitkeep
+0
-0
.gitkeep
answers/tmp/.gitkeep
+0
-0
main.py
comm/server/main.py
+23
-18
pynq-manager.js
comm/server/static/js/pynq-manager.js
+1
-0
No files found.
answers/submit/.gitkeep
0 → 100644
View file @
98831a73
answers/tmp/.gitkeep
0 → 100644
View file @
98831a73
comm/server/main.py
View file @
98831a73
...
...
@@ -32,7 +32,7 @@ app_args = {}
questions
=
None
clients
=
None
current_seed
=
1
wsq
=
None
wsq
=
{}
def
load_questions
():
global
app_args
...
...
@@ -117,7 +117,6 @@ def update_answer_list(qname):
if
answer_log
[
'solved'
]
==
"True"
:
is_solved
=
True
if
questions
[
qname
][
'answer'
]
==
answer_log
[
'answer'
]:
questions
[
qname
][
'best_json'
]
=
json_name
...
...
@@ -213,7 +212,9 @@ def post():
with
open
(
save_file_path
,
"w"
)
as
fp
:
json
.
dump
(
dat
,
fp
,
indent
=
4
)
wsq
.
put
(
dat
)
for
k
,
v
in
wsq
.
items
():
if
v
is
not
None
:
v
.
put
(
dat
)
res
=
{
"status"
:
"OK"
}
...
...
@@ -346,8 +347,12 @@ def save_best_solution():
_best_json
=
""
for
k
,
v
in
questions
[
qname
][
'answers'
]
.
items
():
if
v
[
'nlcheck'
]
>
_best_score
:
_best_socer
=
v
[
'nlcheck'
]
try
:
_score
=
float
(
v
[
'nlcheck'
])
except
:
_score
=
-
1
if
_score
>
_best_score
:
_best_score
=
_score
_best_json
=
k
if
_best_json
!=
""
:
...
...
@@ -355,12 +360,14 @@ def save_best_solution():
if
not
os
.
path
.
isdir
(
out_path
):
os
.
makedirs
(
out_path
)
print
(
"Saved answer for {}: {}"
.
format
(
qname
,
_best_json
))
qnumber
=
qname
.
replace
(
"NL_Q"
,
""
)
.
replace
(
".txt"
,
""
)
out_file_path
=
"{}/T01_A{}.txt"
.
format
(
out_path
,
qnumber
)
with
open
(
out_file_path
,
'w'
)
as
fp
:
fp
.
write
(
questions
[
qname
][
'answers'
][
_best_json
][
'answer'
])
questions
[
_
name
][
"status"
]
=
"Saved"
questions
[
q
name
][
"status"
]
=
"Saved"
questions
[
qname
][
'best_json'
]
=
_best_json
res
=
{
"status"
:
"OK"
}
...
...
@@ -600,15 +607,16 @@ def ws():
if
request
.
environ
.
get
(
'wsgi.websocket'
):
ws
=
request
.
environ
[
'wsgi.websocket'
]
ws_id
=
time
.
time
()
wsq
[
ws_id
]
=
Queue
()
while
True
:
if
wsq
is
None
:
time
.
sleep
(
1
)
continue
else
:
data
=
wsq
.
get
()
data
=
wsq
[
ws_id
]
.
get
()
str_data
=
json
.
dumps
(
data
)
ws
.
send
(
str_data
)
wsq
[
ws_id
]
=
None
@
app
.
route
(
"/"
)
def
index
():
...
...
@@ -653,9 +661,6 @@ def init_system():
if
questions
is
None
:
load_questions
()
if
wsq
is
None
:
wsq
=
Queue
()
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"PYNQ control panel."
)
...
...
comm/server/static/js/pynq-manager.js
View file @
98831a73
...
...
@@ -209,6 +209,7 @@ $(function(){
data
:
{
qname
:
qname
}
}).
done
((
data
)
=>
{
alert
(
data
[
'status'
]);
location
.
reload
();
});
});
$
(
"#client-control-pane"
).
find
(
".submit-button"
).
eq
(
0
).
click
(
function
(){
...
...
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