Skip to content

Commit

Permalink
netrender fix for master receiving files
Browse files Browse the repository at this point in the history
Based on patch [#28108] by Wintch Analyzer
  • Loading branch information
Martin Poirier committed Aug 7, 2011
1 parent 2f80c8d commit cfb12a2
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions netrender/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ def reset(self, all):
edit_pattern = re.compile("/edit_([a-zA-Z0-9]+)")

class RenderHandler(http.server.BaseHTTPRequestHandler):
def write_file(self, file_path, mode = 'wb'):
length = int(self.headers['content-length'])
f = open(file_path, mode)
buf = self.rfile.read(length)
f.write(buf)
f.close()
del buf

def log_message(self, format, *args):
# override because the original calls self.address_string(), which
# is extremely slow due to some timeout..
Expand Down Expand Up @@ -697,6 +705,7 @@ def do_PUT(self):
if match:
self.server.stats("", "Receiving job")

length = int(self.headers['content-length'])
job_id = match.groups()[0]
file_index = int(match.groups()[1])

Expand All @@ -718,10 +727,8 @@ def do_PUT(self):

# add same temp file + renames as slave

f = open(file_path, "wb")
shutil.copyfileobj(self.rfile, f)
f.close()

self.write_file(file_path)

render_file.filepath = file_path # set the new path

if job.testStart():
Expand Down Expand Up @@ -764,9 +771,7 @@ def do_PUT(self):

if job.hasRenderResult():
if job_result == DONE:
f = open(os.path.join(job.save_path, "%06d.exr" % job_frame), 'wb')
shutil.copyfileobj(self.rfile, f)
f.close()
self.write_file(os.path.join(job.save_path, "%06d.exr" % job_frame))

elif job_result == ERROR:
# blacklist slave on this job on error
Expand Down Expand Up @@ -809,9 +814,7 @@ def do_PUT(self):
self.send_head(content = None)

if job.hasRenderResult():
f = open(os.path.join(job.save_path, "%06d.jpg" % job_frame), 'wb')
shutil.copyfileobj(self.rfile, f)
f.close()
os.path.join(os.path.join(job.save_path, "%06d.jpg" % job_frame))

else: # frame not found
self.send_head(http.client.NO_CONTENT)
Expand All @@ -838,9 +841,7 @@ def do_PUT(self):
if frame and frame.log_path:
self.send_head(content = None)

f = open(frame.log_path, 'ab')
shutil.copyfileobj(self.rfile, f)
f.close()
self.write_file(frame.log_path, 'ab')

self.server.getSeenSlave(self.headers['slave-id'])

Expand Down

0 comments on commit cfb12a2

Please sign in to comment.