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
48485307
Commit
48485307
authored
Aug 14, 2018
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change to decide resolver at host
parent
aadb00db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
22 deletions
+46
-22
main.py
comm/server/main.py
+43
-17
index.html
comm/server/templates/index.html
+1
-1
part_question_status.html
comm/server/templates/part_question_status.html
+2
-4
No files found.
comm/server/main.py
View file @
48485307
...
@@ -117,12 +117,18 @@ def post():
...
@@ -117,12 +117,18 @@ def post():
_answer
=
request
.
form
[
"answer"
]
_answer
=
request
.
form
[
"answer"
]
_client
=
request
.
form
[
"client"
]
_client
=
request
.
form
[
"client"
]
if
"solver"
in
request
.
form
:
_solver
=
request
.
form
[
"solver"
]
else
:
_solver
=
_client
receive_time
=
datetime
.
datetime
.
now
()
receive_time
=
datetime
.
datetime
.
now
()
receive_time_str
=
receive_time
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
receive_time_str
=
receive_time
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
dat
=
{
dat
=
{
"req_id"
:
request
.
form
[
'req_id'
],
"req_id"
:
request
.
form
[
'req_id'
],
"client"
:
_client
,
"client"
:
_client
,
"solver"
:
_solver
,
"answer"
:
_answer
,
"answer"
:
_answer
,
"cputime"
:
request
.
form
[
'cputime'
],
"cputime"
:
request
.
form
[
'cputime'
],
"timestamp"
:
receive_time
.
strftime
(
"
%
Y/
%
m/
%
d
%
H:
%
M:
%
S"
)
"timestamp"
:
receive_time
.
strftime
(
"
%
Y/
%
m/
%
d
%
H:
%
M:
%
S"
)
...
@@ -220,10 +226,18 @@ def solve_questions(qname, qstr):
...
@@ -220,10 +226,18 @@ def solve_questions(qname, qstr):
global
questions
global
questions
global
current_seed
global
current_seed
def
worker
(
host
,
qname
,
qstr
,
qseed
,
req_id
):
def
worker
(
host
,
qname
,
qstr
,
qseed
,
req_id
,
resolver
):
_url
=
"http://{}/start"
.
format
(
host
)
_url
=
"http://{}/start"
.
format
(
host
)
data
=
{
"client"
:
host
,
"qname"
:
qname
,
"question"
:
qstr
,
"qseed"
:
qseed
,
"req_id"
:
req_id
,
"resolver"
:
resolver
}
try
:
try
:
r
=
requests
.
post
(
_url
,
data
=
{
"client"
:
host
,
"qname"
:
qname
,
"question"
:
qstr
,
"qseed"
:
qseed
,
"req_id"
:
req_id
}
)
r
=
requests
.
post
(
_url
,
data
=
data
)
client_res
=
json
.
loads
(
r
.
text
)
client_res
=
json
.
loads
(
r
.
text
)
except
Exception
as
e
:
except
Exception
as
e
:
sys
.
stderr
.
write
(
str
(
e
)
+
"
\n
"
)
sys
.
stderr
.
write
(
str
(
e
)
+
"
\n
"
)
...
@@ -234,14 +248,15 @@ def solve_questions(qname, qstr):
...
@@ -234,14 +248,15 @@ def solve_questions(qname, qstr):
req_id
=
time
.
time
()
req_id
=
time
.
time
()
questions
[
qname
][
'last_req'
]
=
req_id
questions
[
qname
][
'last_req'
]
=
req_id
for
c
in
clients
:
for
c
in
clients
[
'solver'
]
:
# 問題はSolverに送る
# 問題はSolverに送る
if
c
[
1
]
==
'Solver'
:
client_addr
=
c
[
0
]
client_addr
=
c
[
0
]
idx_of_resolver
=
current_seed
%
len
(
clients
[
'resolver'
])
_th
=
threading
.
Thread
(
name
=
client_addr
,
target
=
worker
,
args
=
(
client_addr
,
qname
,
qstr
,
current_seed
,
req_id
))
resolver
=
clients
[
'resolver'
][
idx_of_resolver
][
0
]
_th
.
start
()
_th
=
threading
.
Thread
(
name
=
client_addr
,
target
=
worker
,
args
=
(
client_addr
,
qname
,
qstr
,
current_seed
,
req_id
,
resolver
))
threads
.
append
(
_th
)
_th
.
start
()
current_seed
+=
1
threads
.
append
(
_th
)
current_seed
+=
1
res
=
{
"status"
:
"Processed"
}
res
=
{
"status"
:
"Processed"
}
...
@@ -269,7 +284,7 @@ def get_clients():
...
@@ -269,7 +284,7 @@ def get_clients():
res
=
OrderedDict
()
res
=
OrderedDict
()
for
c
in
clients
:
for
c
in
clients
[
'all'
]
:
client_ip
=
c
[
0
]
client_ip
=
c
[
0
]
res
[
client_ip
]
=
"http://{}"
.
format
(
client_ip
)
res
[
client_ip
]
=
"http://{}"
.
format
(
client_ip
)
...
@@ -291,7 +306,7 @@ def client_table():
...
@@ -291,7 +306,7 @@ def client_table():
global
app_args
global
app_args
global
clients
global
clients
return
render_template
(
"part_client_table.html"
,
clients
=
clients
,
local_mode
=
g
.
local_mode
)
return
render_template
(
"part_client_table.html"
,
clients
=
clients
[
"all"
]
,
local_mode
=
g
.
local_mode
)
@
app
.
route
(
"/get_question_status"
)
@
app
.
route
(
"/get_question_status"
)
def
question_status
():
def
question_status
():
...
@@ -305,20 +320,17 @@ def question_status():
...
@@ -305,20 +320,17 @@ def question_status():
update_answer_list
(
qname
)
update_answer_list
(
qname
)
qdata
=
questions
[
qname
]
qdata
=
questions
[
qname
]
return
render_template
(
"part_question_status.html"
,
qname
=
qname
,
qdata
=
qdata
,
clients
=
clients
)
return
render_template
(
"part_question_status.html"
,
qname
=
qname
,
qdata
=
qdata
,
solvers
=
clients
[
"solver"
]
)
@
app
.
route
(
"/"
)
@
app
.
route
(
"/"
)
def
index
():
def
index
():
global
app_args
global
app_args
global
questions
global
questions
global
clients
question_path
=
os
.
path
.
abspath
(
app_args
[
"question"
])
question_path
=
os
.
path
.
abspath
(
app_args
[
"question"
])
print
(
g
.
local_mode
)
return
render_template
(
"index.html"
,
questions
=
questions
,
question_path
=
question_path
)
return
render_template
(
"index.html"
,
questions
=
questions
,
question_path
=
question_path
,
clients
=
clients
)
def
main
(
args
):
def
main
(
args
):
raise
NotImprementedError
()
raise
NotImprementedError
()
...
@@ -337,7 +349,21 @@ def init_system():
...
@@ -337,7 +349,21 @@ def init_system():
with
open
(
app_args
[
"client"
],
"r"
)
as
fp
:
with
open
(
app_args
[
"client"
],
"r"
)
as
fp
:
_clients
=
fp
.
readlines
()
_clients
=
fp
.
readlines
()
clients
=
[
v
.
rstrip
()
.
split
()
for
v
in
_clients
]
all_clients
=
[
v
.
rstrip
()
.
split
()
for
v
in
_clients
]
solver
=
[]
resolver
=
[]
for
v
in
all_clients
:
if
v
[
1
]
.
lower
()
==
"solver"
:
solver
.
append
(
v
)
elif
v
[
1
]
.
lower
()
==
"resolver"
:
resolver
.
append
(
v
)
clients
=
{
"all"
:
all_clients
,
"solver"
:
solver
,
"resolver"
:
resolver
}
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
comm/server/templates/index.html
View file @
48485307
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-5"
id=
"question-control-pane"
>
<div
class=
"col-5"
id=
"question-control-pane"
>
<h3>
問題一覧
</h3>
<h3>
問題一覧
</h3>
<span><a
href=
"/#"
id=
"view-server-status-button"
>
クライアント
状況
</a></span>
<span><a
href=
"/#"
id=
"view-server-status-button"
>
システム
状況
</a></span>
<div
id=
"question-table-wrapper"
>
<div
id=
"question-table-wrapper"
>
<p>
Loading...
</p>
<p>
Loading...
</p>
</div>
</div>
...
...
comm/server/templates/part_question_status.html
View file @
48485307
...
@@ -12,8 +12,7 @@
...
@@ -12,8 +12,7 @@
<th>
Client (Solver)
</th>
<th>
Client (Solver)
</th>
<th>
Status
</th>
<th>
Status
</th>
</tr>
</tr>
{% for c in clients %}
{% for c in solvers %}
{% if c[1] == "Solver" %}
<tr>
<tr>
<td>
<td>
{% if c|length > 3 %}
{% if c|length > 3 %}
...
@@ -26,7 +25,6 @@
...
@@ -26,7 +25,6 @@
</td>
</td>
<td></td>
<td></td>
</tr>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
</table>
</table>
</div>
</div>
...
@@ -43,7 +41,7 @@
...
@@ -43,7 +41,7 @@
{% for v in qdata.answers %}
{% for v in qdata.answers %}
<tr>
<tr>
<td>
{{v.timestamp}}
</td>
<td>
{{v.timestamp}}
</td>
<td>
{{v.
client
}}
</td>
<td>
{{v.
solver
}}
</td>
<td>
{{v.nlcheck}}
</td>
<td>
{{v.nlcheck}}
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
...
...
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