2009-11-01 15:21:20 +00:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
2009-12-15 18:09:01 +00:00
|
|
|
import os
|
2009-09-23 01:59:57 +00:00
|
|
|
import re
|
2009-12-15 18:09:01 +00:00
|
|
|
import shutil
|
2009-09-23 01:59:57 +00:00
|
|
|
from netrender.utils import *
|
|
|
|
|
2009-12-15 18:09:01 +00:00
|
|
|
src_folder = os.path.split(__file__)[0]
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
def get(handler):
|
|
|
|
def output(text):
|
|
|
|
handler.wfile.write(bytes(text, encoding='utf8'))
|
2009-12-15 18:09:01 +00:00
|
|
|
|
|
|
|
def head(title):
|
|
|
|
output("<html><head>")
|
|
|
|
output("<script src='/html/netrender.js' type='text/javascript'></script>")
|
2009-12-20 21:46:39 +00:00
|
|
|
# output("<script src='/html/json2.js' type='text/javascript'></script>")
|
2009-12-15 18:09:01 +00:00
|
|
|
output("<title>")
|
|
|
|
output(title)
|
|
|
|
output("</title></head><body>")
|
2009-12-21 01:09:09 +00:00
|
|
|
output("<link rel='stylesheet' href='/html/netrender.css' type='text/css'>")
|
|
|
|
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
def link(text, url):
|
|
|
|
return "<a href='%s'>%s</a>" % (url, text)
|
|
|
|
|
2009-12-21 19:56:53 +00:00
|
|
|
def startTable(border=1, class_style = None, caption = None):
|
|
|
|
output("<table border='%i'" % border)
|
|
|
|
|
|
|
|
if class_style:
|
|
|
|
output(" class='%s'" % class_style)
|
|
|
|
|
|
|
|
output(">")
|
|
|
|
|
|
|
|
if caption:
|
|
|
|
output("<caption>%s</caption>" % caption)
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
def headerTable(*headers):
|
|
|
|
output("<thead><tr>")
|
|
|
|
|
|
|
|
for c in headers:
|
|
|
|
output("<td>" + c + "</td>")
|
|
|
|
|
|
|
|
output("</tr></thead>")
|
|
|
|
|
2009-12-21 18:14:39 +00:00
|
|
|
def rowTable(*data, id = None, class_style = None, extra = None):
|
|
|
|
output("<tr")
|
|
|
|
|
|
|
|
if id:
|
|
|
|
output(" id='%s'" % id)
|
|
|
|
|
|
|
|
if class_style:
|
|
|
|
output(" class='%s'" % class_style)
|
|
|
|
|
|
|
|
if extra:
|
|
|
|
output(" %s" % extra)
|
|
|
|
|
|
|
|
output(">")
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
for c in data:
|
|
|
|
output("<td>" + str(c) + "</td>")
|
|
|
|
|
|
|
|
output("</tr>")
|
|
|
|
|
|
|
|
def endTable():
|
|
|
|
output("</table>")
|
|
|
|
|
2009-12-15 18:09:01 +00:00
|
|
|
if handler.path == "/html/netrender.js":
|
|
|
|
f = open(os.path.join(src_folder, "netrender.js"), 'rb')
|
|
|
|
|
|
|
|
handler.send_head(content = "text/javascript")
|
|
|
|
shutil.copyfileobj(f, handler.wfile)
|
|
|
|
|
|
|
|
f.close()
|
2009-12-21 01:09:09 +00:00
|
|
|
elif handler.path == "/html/netrender.css":
|
|
|
|
f = open(os.path.join(src_folder, "netrender.css"), 'rb')
|
|
|
|
|
|
|
|
handler.send_head(content = "text/css")
|
|
|
|
shutil.copyfileobj(f, handler.wfile)
|
|
|
|
|
|
|
|
f.close()
|
2009-12-15 18:09:01 +00:00
|
|
|
elif handler.path == "/html" or handler.path == "/":
|
2009-10-01 18:57:22 +00:00
|
|
|
handler.send_head(content = "text/html")
|
2009-12-15 18:09:01 +00:00
|
|
|
head("NetRender")
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
output("<h2>Master</h2>")
|
2009-12-15 18:09:01 +00:00
|
|
|
|
2009-12-21 19:56:53 +00:00
|
|
|
output("""<button title="remove all jobs" onclick="request('/clear', null);">CLEAR JOB LIST</button>""")
|
|
|
|
|
|
|
|
startTable(caption = "Rules", class_style = "rules")
|
|
|
|
|
|
|
|
headerTable("type", "description", "limit")
|
|
|
|
|
|
|
|
for rule in handler.server.balancer.rules:
|
|
|
|
rowTable("rating", rule, rule.str_limit() if hasattr(rule, "limit") else " ")
|
|
|
|
|
|
|
|
for rule in handler.server.balancer.priorities:
|
|
|
|
rowTable("priority", rule, rule.str_limit() if hasattr(rule, "limit") else " ")
|
2009-12-15 18:09:01 +00:00
|
|
|
|
2009-12-21 19:56:53 +00:00
|
|
|
for rule in handler.server.balancer.exceptions:
|
|
|
|
rowTable("exception", rule, rule.str_limit() if hasattr(rule, "limit") else " ")
|
|
|
|
|
|
|
|
endTable()
|
|
|
|
|
2009-09-23 01:59:57 +00:00
|
|
|
output("<h2>Slaves</h2>")
|
|
|
|
|
|
|
|
startTable()
|
2009-09-24 19:52:32 +00:00
|
|
|
headerTable("name", "address", "last seen", "stats", "job")
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
for slave in handler.server.slaves:
|
2009-09-24 19:52:32 +00:00
|
|
|
rowTable(slave.name, slave.address[0], time.ctime(slave.last_seen), slave.stats, link(slave.job.name, "/html/job" + slave.job.id) if slave.job else "None")
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
endTable()
|
|
|
|
|
|
|
|
output("<h2>Jobs</h2>")
|
|
|
|
|
|
|
|
startTable()
|
2009-09-24 21:05:54 +00:00
|
|
|
headerTable(
|
2009-12-20 21:46:39 +00:00
|
|
|
" ",
|
2009-12-21 01:09:09 +00:00
|
|
|
"id",
|
2009-09-24 21:05:54 +00:00
|
|
|
"name",
|
2009-12-10 18:56:21 +00:00
|
|
|
"category",
|
2009-12-20 21:46:39 +00:00
|
|
|
"chunks",
|
2009-09-24 21:05:54 +00:00
|
|
|
"priority",
|
|
|
|
"usage",
|
|
|
|
"wait",
|
2009-12-16 21:00:25 +00:00
|
|
|
"status",
|
2009-09-24 21:05:54 +00:00
|
|
|
"length",
|
|
|
|
"done",
|
|
|
|
"dispatched",
|
|
|
|
"error",
|
|
|
|
"first",
|
|
|
|
"exception"
|
|
|
|
)
|
2009-09-23 21:46:29 +00:00
|
|
|
|
2009-09-26 16:22:52 +00:00
|
|
|
handler.server.balance()
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
for job in handler.server.jobs:
|
|
|
|
results = job.framesStatus()
|
2009-09-24 21:05:54 +00:00
|
|
|
rowTable(
|
2009-12-21 01:09:09 +00:00
|
|
|
"""<button title="cancel job" onclick="request('/cancel_%s', null);">X</button>""" % job.id +
|
2009-12-20 21:46:39 +00:00
|
|
|
"""<button title="reset all frames" onclick="request('/resetall_%s_0', null);">R</button>""" % job.id,
|
2009-12-21 01:09:09 +00:00
|
|
|
job.id,
|
2009-09-24 21:05:54 +00:00
|
|
|
link(job.name, "/html/job" + job.id),
|
2009-12-20 21:46:39 +00:00
|
|
|
job.category if job.category else "<i>None</i>",
|
|
|
|
str(job.chunks) +
|
|
|
|
"""<button title="increase priority" onclick="request('/edit_%s', "{'chunks': %i}");">+</button>""" % (job.id, job.chunks + 1) +
|
|
|
|
"""<button title="decrease priority" onclick="request('/edit_%s', "{'chunks': %i}");" %s>-</button>""" % (job.id, job.chunks - 1, "disabled=True" if job.chunks == 1 else ""),
|
|
|
|
str(job.priority) +
|
2009-12-21 01:09:09 +00:00
|
|
|
"""<button title="increase chunks size" onclick="request('/edit_%s', "{'priority': %i}");">+</button>""" % (job.id, job.priority + 1) +
|
|
|
|
"""<button title="decrease chunks size" onclick="request('/edit_%s', "{'priority': %i}");" %s>-</button>""" % (job.id, job.priority - 1, "disabled=True" if job.priority == 1 else ""),
|
2009-09-24 19:52:32 +00:00
|
|
|
"%0.1f%%" % (job.usage * 100),
|
2009-09-24 21:05:54 +00:00
|
|
|
"%is" % int(time.time() - job.last_dispatched),
|
2009-12-16 21:00:25 +00:00
|
|
|
job.statusText(),
|
2009-09-24 19:52:32 +00:00
|
|
|
len(job),
|
|
|
|
results[DONE],
|
|
|
|
results[DISPATCHED],
|
2009-12-20 21:46:39 +00:00
|
|
|
str(results[ERROR]) +
|
|
|
|
"""<button title="reset error frames" onclick="request('/reset_%s_0', null);" %s>R</button>""" % (job.id, "disabled=True" if not results[ERROR] else ""),
|
2009-09-24 19:52:32 +00:00
|
|
|
handler.server.balancer.applyPriorities(job), handler.server.balancer.applyExceptions(job)
|
2009-09-24 21:05:54 +00:00
|
|
|
)
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
endTable()
|
|
|
|
|
|
|
|
output("</body></html>")
|
|
|
|
|
|
|
|
elif handler.path.startswith("/html/job"):
|
2009-10-01 18:57:22 +00:00
|
|
|
handler.send_head(content = "text/html")
|
2009-09-23 01:59:57 +00:00
|
|
|
job_id = handler.path[9:]
|
|
|
|
|
2009-12-15 18:09:01 +00:00
|
|
|
head("NetRender")
|
2009-09-23 01:59:57 +00:00
|
|
|
|
2009-09-26 16:22:52 +00:00
|
|
|
job = handler.server.getJobID(job_id)
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
if job:
|
2009-12-19 22:36:20 +00:00
|
|
|
output("<h2>Files</h2>")
|
|
|
|
|
|
|
|
startTable()
|
|
|
|
headerTable("path")
|
|
|
|
|
|
|
|
tot_cache = 0
|
|
|
|
tot_fluid = 0
|
|
|
|
|
|
|
|
for file in job.files:
|
|
|
|
if file.filepath.endswith(".bphys"):
|
|
|
|
tot_cache += 1
|
|
|
|
elif file.filepath.endswith(".bobj.gz") or file.filepath.endswith(".bvel.gz"):
|
|
|
|
tot_fluid += 1
|
|
|
|
else:
|
|
|
|
rowTable(file.filepath)
|
|
|
|
|
|
|
|
if tot_cache > 0:
|
2009-12-21 18:14:39 +00:00
|
|
|
rowTable("%i physic cache files" % tot_cache, class_style = "toggle", extra = "onclick='toggleDisplay(".cache", "none", "table-row")'")
|
|
|
|
for file in job.files:
|
|
|
|
if file.filepath.endswith(".bphys"):
|
|
|
|
rowTable(os.path.split(file.filepath)[1], class_style = "cache")
|
2009-12-19 22:36:20 +00:00
|
|
|
|
|
|
|
if tot_fluid > 0:
|
2009-12-21 18:14:39 +00:00
|
|
|
rowTable("%i fluid bake files" % tot_fluid, class_style = "toggle", extra = "onclick='toggleDisplay(".fluid", "none", "table-row")'")
|
|
|
|
for file in job.files:
|
|
|
|
if file.filepath.endswith(".bobj.gz") or file.filepath.endswith(".bvel.gz"):
|
|
|
|
rowTable(os.path.split(file.filepath)[1], class_style = "fluid")
|
2009-12-19 22:36:20 +00:00
|
|
|
|
|
|
|
endTable()
|
|
|
|
|
2009-12-20 21:46:39 +00:00
|
|
|
output("<h2>Blacklist</h2>")
|
|
|
|
|
|
|
|
if job.blacklist:
|
|
|
|
startTable()
|
|
|
|
headerTable("name", "address")
|
|
|
|
|
|
|
|
for slave_id in job.blacklist:
|
|
|
|
slave = handler.server.slaves_map[slave_id]
|
|
|
|
rowTable(slave.name, slave.address[0])
|
|
|
|
|
|
|
|
endTable()
|
|
|
|
else:
|
|
|
|
output("<i>Empty</i>")
|
|
|
|
|
2009-09-23 01:59:57 +00:00
|
|
|
output("<h2>Frames</h2>")
|
|
|
|
|
|
|
|
startTable()
|
2009-12-14 23:09:08 +00:00
|
|
|
headerTable("no", "status", "render time", "slave", "log", "result")
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
for frame in job.frames:
|
2009-12-14 23:09:08 +00:00
|
|
|
rowTable(frame.number, frame.statusText(), "%.1fs" % frame.time, frame.slave.name if frame.slave else " ", link("view log", logURL(job_id, frame.number)) if frame.log_path else " ", link("view result", renderURL(job_id, frame.number)) if frame.status == DONE else " ")
|
2009-09-23 01:59:57 +00:00
|
|
|
|
|
|
|
endTable()
|
|
|
|
else:
|
|
|
|
output("no such job")
|
|
|
|
|
|
|
|
output("</body></html>")
|
2009-12-14 23:09:08 +00:00
|
|
|
|