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
22ea331a
Commit
22ea331a
authored
Aug 23, 2018
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'comm-server' into 'comm'
Merge comm-server See merge request adc2018/adc2018-system!19
parents
ed903e2f
847ec31f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
13 deletions
+14
-13
main.py
comm/server/main.py
+13
-13
pynq-manager.js
comm/server/static/js/pynq-manager.js
+1
-0
No files found.
comm/server/main.py
View file @
22ea331a
...
@@ -32,7 +32,7 @@ app_args = {}
...
@@ -32,7 +32,7 @@ app_args = {}
questions
=
None
questions
=
None
clients
=
None
clients
=
None
current_seed
=
1
current_seed
=
1
wsq
=
None
wsq
=
{}
def
load_questions
():
def
load_questions
():
global
app_args
global
app_args
...
@@ -213,7 +213,9 @@ def post():
...
@@ -213,7 +213,9 @@ def post():
with
open
(
save_file_path
,
"w"
)
as
fp
:
with
open
(
save_file_path
,
"w"
)
as
fp
:
json
.
dump
(
dat
,
fp
,
indent
=
4
)
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"
}
res
=
{
"status"
:
"OK"
}
...
@@ -360,7 +362,7 @@ def save_best_solution():
...
@@ -360,7 +362,7 @@ def save_best_solution():
with
open
(
out_file_path
,
'w'
)
as
fp
:
with
open
(
out_file_path
,
'w'
)
as
fp
:
fp
.
write
(
questions
[
qname
][
'answers'
][
_best_json
][
'answer'
])
fp
.
write
(
questions
[
qname
][
'answers'
][
_best_json
][
'answer'
])
questions
[
_
name
][
"status"
]
=
"Saved"
questions
[
q
name
][
"status"
]
=
"Saved"
questions
[
qname
][
'best_json'
]
=
_best_json
questions
[
qname
][
'best_json'
]
=
_best_json
res
=
{
"status"
:
"OK"
}
res
=
{
"status"
:
"OK"
}
...
@@ -600,15 +602,16 @@ def ws():
...
@@ -600,15 +602,16 @@ def ws():
if
request
.
environ
.
get
(
'wsgi.websocket'
):
if
request
.
environ
.
get
(
'wsgi.websocket'
):
ws
=
request
.
environ
[
'wsgi.websocket'
]
ws
=
request
.
environ
[
'wsgi.websocket'
]
ws_id
=
time
.
time
()
wsq
[
ws_id
]
=
Queue
()
while
True
:
while
True
:
if
wsq
is
None
:
data
=
wsq
[
ws_id
]
.
get
()
time
.
sleep
(
1
)
continue
else
:
data
=
wsq
.
get
()
str_data
=
json
.
dumps
(
data
)
str_data
=
json
.
dumps
(
data
)
ws
.
send
(
str_data
)
ws
.
send
(
str_data
)
wsq
[
ws_id
]
=
None
@
app
.
route
(
"/"
)
@
app
.
route
(
"/"
)
def
index
():
def
index
():
...
@@ -653,9 +656,6 @@ def init_system():
...
@@ -653,9 +656,6 @@ def init_system():
if
questions
is
None
:
if
questions
is
None
:
load_questions
()
load_questions
()
if
wsq
is
None
:
wsq
=
Queue
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"PYNQ control panel."
)
parser
=
argparse
.
ArgumentParser
(
description
=
"PYNQ control panel."
)
...
...
comm/server/static/js/pynq-manager.js
View file @
22ea331a
...
@@ -209,6 +209,7 @@ $(function(){
...
@@ -209,6 +209,7 @@ $(function(){
data
:
{
qname
:
qname
}
data
:
{
qname
:
qname
}
}).
done
((
data
)
=>
{
}).
done
((
data
)
=>
{
alert
(
data
[
'status'
]);
alert
(
data
[
'status'
]);
location
.
reload
();
});
});
});
});
$
(
"#client-control-pane"
).
find
(
".submit-button"
).
eq
(
0
).
click
(
function
(){
$
(
"#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