forked from bartvdbraak/blender
fix bugs with file transfer
This commit is contained in:
parent
b6c6610630
commit
6e4d4a8a12
@ -323,8 +323,9 @@ class RenderHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
if render_file:
|
if render_file:
|
||||||
self.server.stats("", "Sending file to render node")
|
self.server.stats("", "Sending file to render node")
|
||||||
f = open(render_file.path, 'rb')
|
f = open(render_file.filepath, 'rb')
|
||||||
|
|
||||||
|
self.send_head()
|
||||||
shutil.copyfileobj(f, self.wfile)
|
shutil.copyfileobj(f, self.wfile)
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
@ -444,7 +445,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
render_file = job.files_map.get(job_file, None)
|
render_file = job.files_map.get(job_file, None)
|
||||||
|
|
||||||
if render_file:
|
if render_file:
|
||||||
main_file = job.files[0]
|
main_file = job.files[0][0] # filename of the first file
|
||||||
|
|
||||||
main_path, main_name = os.path.split(main_file)
|
main_path, main_name = os.path.split(main_file)
|
||||||
|
|
||||||
@ -462,12 +463,12 @@ class RenderHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
f.close()
|
f.close()
|
||||||
del buf
|
del buf
|
||||||
|
|
||||||
render_file.path = file_path # set the new path
|
render_file.filepath = file_path # set the new path
|
||||||
|
|
||||||
if job.testStart():
|
if job.testStart():
|
||||||
self.send_head(headers=headers)
|
self.send_head(http.client.OK)
|
||||||
else:
|
else:
|
||||||
self.send_head(http.client.ACCEPTED, headers=headers)
|
self.send_head(http.client.ACCEPTED)
|
||||||
else: # invalid file
|
else: # invalid file
|
||||||
self.send_head(http.client.NO_CONTENT)
|
self.send_head(http.client.NO_CONTENT)
|
||||||
else: # job not found
|
else: # job not found
|
||||||
|
@ -26,12 +26,12 @@ def testCancel(conn, job_id):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def testFile(conn, JOB_PREFIX, file_path, main_path = None):
|
def testFile(conn, job_id, slave_id, JOB_PREFIX, file_path, main_path = None):
|
||||||
job_full_path = prefixPath(JOB_PREFIX, file_path, main_path)
|
job_full_path = prefixPath(JOB_PREFIX, file_path, main_path)
|
||||||
|
|
||||||
if not os.path.exists(job_full_path):
|
if not os.path.exists(job_full_path):
|
||||||
temp_path = JOB_PREFIX + "slave.temp.blend"
|
temp_path = JOB_PREFIX + "slave.temp.blend"
|
||||||
conn.request("GET", "file", headers={"job-id": job.id, "slave-id":slave_id, "job-file":file_path})
|
conn.request("GET", "file", headers={"job-id": job_id, "slave-id":slave_id, "job-file":file_path})
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
|
|
||||||
if response.status != http.client.OK:
|
if response.status != http.client.OK:
|
||||||
@ -86,14 +86,14 @@ def render_slave(engine, scene):
|
|||||||
job_path = job.files[0][0] # data in files have format (path, start, end)
|
job_path = job.files[0][0] # data in files have format (path, start, end)
|
||||||
main_path, main_file = os.path.split(job_path)
|
main_path, main_file = os.path.split(job_path)
|
||||||
|
|
||||||
job_full_path = testFile(conn, JOB_PREFIX, job_path)
|
job_full_path = testFile(conn, job.id, slave_id, JOB_PREFIX, job_path)
|
||||||
print("Fullpath", job_full_path)
|
print("Fullpath", job_full_path)
|
||||||
print("File:", main_file, "and %i other files" % (len(job.files) - 1,))
|
print("File:", main_file, "and %i other files" % (len(job.files) - 1,))
|
||||||
engine.update_stats("", "Render File", main_file, "for job", job.id)
|
engine.update_stats("", "Render File", main_file, "for job", job.id)
|
||||||
|
|
||||||
for file_path, start, end in job.files[1:]:
|
for file_path, start, end in job.files[1:]:
|
||||||
print("\t", file_path)
|
print("\t", file_path)
|
||||||
testFile(conn, JOB_PREFIX, file_path, main_path)
|
testFile(conn, job.id, slave_id, JOB_PREFIX, file_path, main_path)
|
||||||
|
|
||||||
frame_args = []
|
frame_args = []
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ def prefixPath(prefix_directory, file_path, prefix_path):
|
|||||||
if not os.path.exists(full_path):
|
if not os.path.exists(full_path):
|
||||||
p, n = os.path.split(full_path)
|
p, n = os.path.split(full_path)
|
||||||
|
|
||||||
if main_path and p.startswith(main_path):
|
if prefix_path and p.startswith(prefix_path):
|
||||||
directory = prefix_directory + p[len(main_path):]
|
directory = prefix_directory + p[len(prefix_path):]
|
||||||
full_path = directory + n
|
full_path = directory + n
|
||||||
if not os.path.exists(directory):
|
if not os.path.exists(directory):
|
||||||
os.mkdir(directory)
|
os.mkdir(directory)
|
||||||
|
Loading…
Reference in New Issue
Block a user