forked from bartvdbraak/blender
netrender: buttons to change chunks, priority and reset job.
This commit is contained in:
parent
2b69661805
commit
85556a780c
@ -80,6 +80,16 @@ class MRenderJob(netrender.model.RenderJob):
|
||||
f = open(self.save_path + "job.txt", "w")
|
||||
f.write(repr(self.serialize()))
|
||||
f.close()
|
||||
|
||||
def edit(self, info_map):
|
||||
if "status" in info_map:
|
||||
self.status = info_map["status"]
|
||||
|
||||
if "priority" in info_map:
|
||||
self.priority = info_map["priority"]
|
||||
|
||||
if "chunks" in info_map:
|
||||
self.chunks = info_map["chunks"]
|
||||
|
||||
def testStart(self):
|
||||
for f in self.files:
|
||||
@ -156,6 +166,7 @@ render_pattern = re.compile("/render_([a-zA-Z0-9]+)_([0-9]+).exr")
|
||||
log_pattern = re.compile("/log_([a-zA-Z0-9]+)_([0-9]+).log")
|
||||
reset_pattern = re.compile("/reset(all|)_([a-zA-Z0-9]+)_([0-9]+)")
|
||||
cancel_pattern = re.compile("/cancel_([a-zA-Z0-9]+)")
|
||||
edit_pattern = re.compile("/edit_([a-zA-Z0-9]+)")
|
||||
|
||||
class RenderHandler(http.server.BaseHTTPRequestHandler):
|
||||
def send_head(self, code = http.client.OK, headers = {}, content = "application/octet-stream"):
|
||||
@ -424,6 +435,27 @@ class RenderHandler(http.server.BaseHTTPRequestHandler):
|
||||
self.server.stats("", "New job, missing files (%i total)" % len(job.files))
|
||||
self.send_head(http.client.ACCEPTED, headers=headers)
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
elif self.path.startswith("/edit"):
|
||||
match = edit_pattern.match(self.path)
|
||||
|
||||
if match:
|
||||
job_id = match.groups()[0]
|
||||
|
||||
job = self.server.getJobID(job_id)
|
||||
|
||||
if job:
|
||||
length = int(self.headers['content-length'])
|
||||
info_map = eval(str(self.rfile.read(length), encoding='utf8'))
|
||||
|
||||
job.edit(info_map)
|
||||
self.send_head()
|
||||
else:
|
||||
# no such job id
|
||||
self.send_head(http.client.NO_CONTENT)
|
||||
else:
|
||||
# invalid url
|
||||
self.send_head(http.client.NO_CONTENT)
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
elif self.path.startswith("/cancel"):
|
||||
match = cancel_pattern.match(self.path)
|
||||
|
||||
@ -608,7 +640,9 @@ class RenderHandler(http.server.BaseHTTPRequestHandler):
|
||||
del buf
|
||||
elif job_result == ERROR:
|
||||
# blacklist slave on this job on error
|
||||
job.blacklist.append(slave.id)
|
||||
# slaves might already be in blacklist if errors on the whole chunk
|
||||
if not slave.id in job.blacklist:
|
||||
job.blacklist.append(slave.id)
|
||||
|
||||
self.server.stats("", "Receiving result")
|
||||
|
||||
|
@ -30,6 +30,7 @@ def get(handler):
|
||||
def head(title):
|
||||
output("<html><head>")
|
||||
output("<script src='/html/netrender.js' type='text/javascript'></script>")
|
||||
# output("<script src='/html/json2.js' type='text/javascript'></script>")
|
||||
output("<title>")
|
||||
output(title)
|
||||
output("</title></head><body>")
|
||||
@ -88,9 +89,11 @@ def get(handler):
|
||||
|
||||
startTable()
|
||||
headerTable(
|
||||
" ",
|
||||
" ",
|
||||
"name",
|
||||
"category",
|
||||
"chunks",
|
||||
"priority",
|
||||
"usage",
|
||||
"wait",
|
||||
@ -99,7 +102,6 @@ def get(handler):
|
||||
"done",
|
||||
"dispatched",
|
||||
"error",
|
||||
" ",
|
||||
"first",
|
||||
"exception"
|
||||
)
|
||||
@ -110,17 +112,23 @@ def get(handler):
|
||||
results = job.framesStatus()
|
||||
rowTable(
|
||||
"""<button title="cancel job" onclick="request('/cancel_%s', null);">X</button>""" % job.id,
|
||||
"""<button title="reset all frames" onclick="request('/resetall_%s_0', null);">R</button>""" % job.id,
|
||||
link(job.name, "/html/job" + job.id),
|
||||
job.category if job.category else " ",
|
||||
job.priority,
|
||||
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) +
|
||||
"""<button title="increase priority" onclick="request('/edit_%s', "{'priority': %i}");">+</button>""" % (job.id, job.priority + 1) +
|
||||
"""<button title="decrease priority" onclick="request('/edit_%s', "{'priority': %i}");" %s>-</button>""" % (job.id, job.priority - 1, "disabled=True" if job.priority == 1 else ""),
|
||||
"%0.1f%%" % (job.usage * 100),
|
||||
"%is" % int(time.time() - job.last_dispatched),
|
||||
job.statusText(),
|
||||
len(job),
|
||||
results[DONE],
|
||||
results[DISPATCHED],
|
||||
results[ERROR],
|
||||
"""<button title="reset error frames" onclick="request('/reset_%s_0', null);">R</button>""" % job.id,
|
||||
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 ""),
|
||||
handler.server.balancer.applyPriorities(job), handler.server.balancer.applyExceptions(job)
|
||||
)
|
||||
|
||||
@ -161,6 +169,20 @@ def get(handler):
|
||||
|
||||
endTable()
|
||||
|
||||
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>")
|
||||
|
||||
output("<h2>Frames</h2>")
|
||||
|
||||
startTable()
|
||||
|
@ -1,26 +1,10 @@
|
||||
function post_to_url(path, params, method) {
|
||||
method = method || "post"; // Set method to post by default, if not specified.
|
||||
|
||||
var form = document.createElement("form");
|
||||
form.setAttribute("method", method);
|
||||
form.setAttribute("action", path);
|
||||
|
||||
for(var key in params) {
|
||||
var hiddenField = document.createElement("input");
|
||||
hiddenField.setAttribute("type", "hidden");
|
||||
hiddenField.setAttribute("name", key);
|
||||
hiddenField.setAttribute("value", params[key]);
|
||||
|
||||
form.appendChild(hiddenField);
|
||||
}
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function request(url, data) {
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.open("POST", url, false);
|
||||
xmlhttp.send(data);
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
function edit(id, info) {
|
||||
request("/edit_" + id, info)
|
||||
}
|
Loading…
Reference in New Issue
Block a user