netrender: utility function to extract information from a blend file on disk. Used to get render resolution for jobs in the web interface (lazy init).
This commit is contained in:
@@ -76,6 +76,12 @@ class MRenderJob(netrender.model.RenderJob):
|
||||
self.save_path = ""
|
||||
self.files = [MRenderFile(rfile.filepath, rfile.index, rfile.start, rfile.end) for rfile in job_info.files]
|
||||
|
||||
self.resolution = None
|
||||
|
||||
def initInfo(self):
|
||||
if not self.resolution:
|
||||
self.resolution = tuple(getFileInfo(self.files[0].filepath, ["bpy.context.scene.render_data.resolution_x", "bpy.context.scene.render_data.resolution_y", "bpy.context.scene.render_data.resolution_percentage"]))
|
||||
|
||||
def save(self):
|
||||
if self.save_path:
|
||||
f = open(self.save_path + "job.txt", "w")
|
||||
@@ -98,6 +104,7 @@ class MRenderJob(netrender.model.RenderJob):
|
||||
return False
|
||||
|
||||
self.start()
|
||||
self.initInfo()
|
||||
return True
|
||||
|
||||
def testFinished(self):
|
||||
|
||||
@@ -215,6 +215,17 @@ def get(handler):
|
||||
job = handler.server.getJobID(job_id)
|
||||
|
||||
if job:
|
||||
output("<h2>Render Information</h2>")
|
||||
|
||||
job.initInfo()
|
||||
|
||||
startTable()
|
||||
|
||||
rowTable("resolution", "%ix%i at %i%%" % job.resolution)
|
||||
|
||||
endTable()
|
||||
|
||||
|
||||
output("<h2>Files</h2>")
|
||||
|
||||
startTable()
|
||||
|
||||
@@ -173,6 +173,21 @@ def prefixPath(prefix_directory, file_path, prefix_path):
|
||||
|
||||
return full_path
|
||||
|
||||
def getFileInfo(filepath, infos):
|
||||
process = subprocess.Popen([sys.argv[0], "-b", "-noaudio", filepath, "-P", __file__, "--"] + infos, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
stdout = bytes()
|
||||
while process.poll() == None:
|
||||
stdout += process.stdout.read(1024)
|
||||
|
||||
# read leftovers if needed
|
||||
stdout += process.stdout.read()
|
||||
|
||||
stdout = str(stdout, encoding="utf8")
|
||||
|
||||
values = [eval(v[1:].strip()) for v in stdout.split("\n") if v.startswith("$")]
|
||||
|
||||
return values
|
||||
|
||||
def thumbnail(filename):
|
||||
root = os.path.splitext(filename)[0]
|
||||
imagename = os.path.split(filename)[1]
|
||||
@@ -197,3 +212,8 @@ def thumbnail(filename):
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
if __name__ == "__main__":
|
||||
import bpy
|
||||
for info in sys.argv[7:]:
|
||||
print("$", eval(info))
|
||||
|
||||
Reference in New Issue
Block a user