Commit 2c2de5e9 authored by Christopher Gearhart's avatar Christopher Gearhart

Improved validation of render dump folder.

parent 24e840db
......@@ -619,7 +619,8 @@ class openRenderedAnimationInUI(Operator):
# opens first frame of image sequence (blender imports full sequence)
openedFile = False
image_sequence_filepath = "{dumpFolder}/".format(dumpFolder=getRenderDumpFolder())
self.renderDumpFolder = getRenderDumpFolder()
image_sequence_filepath = "{dumpFolder}/".format(dumpFolder=self.renderDumpFolder)
for frame in bpy.props.animFrameRange:
try:
print("entering try")
......@@ -637,7 +638,7 @@ class openRenderedAnimationInUI(Operator):
bpy.data.movieclips[openedFile].frame_start = frame
else:
changeContext(context, lastAreaType)
self.report({"ERROR"}, "Could not open rendered animation. View files in file browser in the following folder: '{renderDumpFolder}'.".format(renderDumpFolder=getRenderDumpFolder()))
self.report({"ERROR"}, "Could not open rendered animation. View files in file browser in the following folder: '{renderDumpFolder}'.".format(renderDumpFolder=self.renderDumpFolder))
return{"FINISHED"}
......
......@@ -259,6 +259,8 @@ def getRenderDumpFolder():
# if no user input, use default render location
else:
dumpLoc = os.path.join(bpy.path.abspath("//"), "render-dump")
# cleanse input
# TODO: throw error if dumpLoc contains backslash
# check to make sure dumpLoc exists on local machine
if not os.path.exists(dumpLoc):
os.mkdir(dumpLoc)
......@@ -268,12 +270,12 @@ def getRunningStatuses():
return ["Rendering...", "Preparing files...", "Finishing..."]
def getNameOutputFiles():
"""return nameOutputFiles, or current project name if nameOutputFiles not specified"""
scn = bpy.context.scene
# remove illegal characters
for char in "/<>:\"\ |?*":
scn.nameOutputFiles = scn.nameOutputFiles.replace(char, "")
# return nameOutputFiles, or projectName if nameOutputFiles not specified
if scn.nameOutputFiles != "":
# remove illegal characters
for char in "/<>:\"\ |?*":
scn.nameOutputFiles = scn.nameOutputFiles.replace(char, "_")
return scn.nameOutputFiles
else:
return bpy.path.display_name_from_filepath(bpy.data.filepath).replace(" ", "_")
......
......@@ -21,40 +21,48 @@ Created by Christopher Gearhart
# system imports
import bpy
from . import getRenderDumpFolder
def jobIsValid(jobType, classObject):
""" verifies that the job is valid before sending it to the host server """
jobValidityDict = False
scn = bpy.context.scene
# verify that project has been saved
if classObject.projectName == "":
jobValidityDict = {"valid":False, "errorType":"WARNING", "errorMessage":"RENDER FAILED: You have not saved your project file. Please save it before attempting to render."}
# verify that a camera exists in the scene
elif bpy.context.scene.camera is None:
elif scn.camera is None:
jobValidityDict = {"valid":False, "errorType":"ERROR", "errorMessage":"RENDER FAILED: No camera in scene."}
# verify image file format
unsupportedFormats = ["AVI_JPEG", "AVI_RAW", "FRAMESERVER", "H264", "FFMPEG", "THEORA", "QUICKTIME", "XVID"]
if not jobValidityDict and bpy.context.scene.render.image_settings.file_format in unsupportedFormats:
if not jobValidityDict and scn.render.image_settings.file_format in unsupportedFormats:
jobValidityDict = {"valid":False, "errorType":"ERROR", "errorMessage":"RENDER FAILED: Output file format not supported. Supported formats: BMP, PNG, TARGA, JPEG, JPEG 2000, TIFF. (Animation only: IRIS, CINEON, HDR, DPX, OPEN_EXR, OPEN_EXR_MULTILAYER)"}
# verify that sampling is high enough to provide expected results
if not jobValidityDict and jobType == "image":
if bpy.context.scene.cycles.progressive == "PATH":
samples = bpy.context.scene.cycles.samples
if bpy.context.scene.cycles.use_square_samples:
if scn.cycles.progressive == "PATH":
samples = scn.cycles.samples
if scn.cycles.use_square_samples:
samples = samples**2
if samples < 10:
jobValidityDict = {"valid":True, "errorType":"WARNING", "errorMessage":"RENDER ALERT: Render result may be inaccurate at {samples} samples. Try 10 or more samples for a more accurate render.".format(samples=str(samples))}
elif bpy.context.scene.cycles.progressive == "BRANCHED_PATH":
samples = bpy.context.scene.cycles.aa_samples
if bpy.context.scene.cycles.use_square_samples:
elif scn.cycles.progressive == "BRANCHED_PATH":
samples = scn.cycles.aa_samples
if scn.cycles.use_square_samples:
samples = samples**2
if samples < 5:
jobValidityDict = {"valid":True, "errorType":"WARNING", "errorMessage":"RENDER ALERT: Render result may be inaccurate at {samples} AA samples. Try 5 or more AA samples for a more accurate render.".format(samples=str(samples))}
# verify that the user input for renderDumpLoc is valid and can be created
try:
rdf = getRenderDumpFolder()
except:
jobValidityDict = {"valid":False, "errorType":"ERROR", "errorMessage":"The folder '{renderDumpFolder}' could not be created on your local machine. Verify your input and write permissions or try another filepath.".format(renderDumpFolder=scn.renderDumpLoc)}
# else, the job is valid
if not jobValidityDict:
jobValidityDict = {"valid":True, "errorType":None, "errorMessage":None}
......@@ -65,9 +73,9 @@ def jobIsValid(jobType, classObject):
# else alert user that render job has started
else:
if jobType == "image":
classObject.report({"INFO"}, "Rendering current frame on {numAvailable} servers (Preview with 'SHIFT + P')".format(numAvailable=str(bpy.context.scene.availableServers)))
classObject.report({"INFO"}, "Rendering current frame on {numAvailable} servers (Preview with 'SHIFT + P')".format(numAvailable=str(scn.availableServers)))
else:
classObject.report({"INFO"}, "Rendering animation on {numAvailable} servers (Check status with 'SHIFT + P')".format(numAvailable=str(bpy.context.scene.availableServers)))
classObject.report({"INFO"}, "Rendering animation on {numAvailable} servers (Check status with 'SHIFT + P')".format(numAvailable=str(scn.availableServers)))
# if job is invalid, return false
if not jobValidityDict["valid"]:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment