Commit 57cb8f50 authored by Christopher Gearhart's avatar Christopher Gearhart

Improvements to memory cleaning, added protection for denoising, protected…

Improvements to memory cleaning, added protection for denoising, protected against blender file names with problematic characters, improved some functions in common_functions
parent ee42360f
No preview for this file type
......@@ -31,23 +31,28 @@ Created by Christopher Gearhart
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# system imports
# System imports
#None!!
# Blender imports
import bpy
from bpy.types import Operator
from bpy.props import *
#Rebrickr imports
from .ui import *
from .buttons import *
from .functions.setupServers import *
# Used to store keymaps for addon
addon_keymaps = []
def more_menu_options(self, context):
layout = self.layout
layout.separator()
layout.operator("scene.render_frame_on_servers", text="Render Image on Servers", icon='RENDER_STILL')
layout.operator("scene.render_animation_on_servers", text="Render Animation on Servers", icon='RENDER_ANIMATION')
# store keymaps here to access after registration
addon_keymaps = []
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_render.append(more_menu_options)
......@@ -142,46 +147,59 @@ def register():
# handle the keymap
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
kmi = km.keymap_items.new("scene.render_frame_on_servers", 'F12', 'PRESS', alt=True)
kmi = km.keymap_items.new("scene.render_animation_on_servers", 'F12', 'PRESS', alt=True, shift=True)
kmi = km.keymap_items.new("scene.open_rendered_image", 'O', 'PRESS', shift=True)
kmi = km.keymap_items.new("scene.open_rendered_animation", 'O', 'PRESS', alt=True, shift=True)
kmi = km.keymap_items.new("scene.list_frames", 'M', 'PRESS', shift=True)
kmi = km.keymap_items.new("scene.set_to_missing_frames", 'M', 'PRESS', alt=True, shift=True)
kmi = km.keymap_items.new("scene.refresh_num_available_servers", 'R', 'PRESS', ctrl=True)
kmi = km.keymap_items.new("scene.edit_servers_dict", 'E', 'PRESS', ctrl=True)
addon_keymaps.append(km)
# Note that in background mode (no GUI available), keyconfigs are not available either, so we have
# to check this to avoid nasty errors in background case.
kc = wm.keyconfigs.addon
if kc:
km = kc.keymaps.new(name='Object Mode', space_type='EMPTY')
kmi = km.keymap_items.new("scene.render_frame_on_servers", 'F12', 'PRESS', alt=True)
kmi = km.keymap_items.new("scene.render_animation_on_servers", 'F12', 'PRESS', alt=True, shift=True)
kmi = km.keymap_items.new("scene.open_rendered_image", 'O', 'PRESS', shift=True)
kmi = km.keymap_items.new("scene.open_rendered_animation", 'O', 'PRESS', alt=True, shift=True)
kmi = km.keymap_items.new("scene.list_frames", 'M', 'PRESS', shift=True)
kmi = km.keymap_items.new("scene.set_to_missing_frames", 'M', 'PRESS', alt=True, shift=True)
kmi = km.keymap_items.new("scene.refresh_num_available_servers", 'R', 'PRESS', ctrl=True)
kmi = km.keymap_items.new("scene.edit_servers_dict", 'E', 'PRESS', ctrl=True)
addon_keymaps.append(km)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_render.remove(more_menu_options)
del bpy.types.Scene.showAdvanced
del bpy.types.Scene.frameRanges
del bpy.types.Scene.tempLocalDir
del bpy.types.Scene.renderDumpLoc
del bpy.types.Scene.nameOutputFiles
del bpy.types.Scene.maxServerLoad
del bpy.types.Scene.timeout
del bpy.types.Scene.maxSamples
del bpy.types.Scene.renderType
del bpy.types.Scene.killPython
del bpy.types.Scene.renderStatus
del bpy.props.serverPrefs
del bpy.props.animFrameRange
del bpy.props.lastRemotePath
del bpy.props.nameAveragedImage
del bpy.props.imExtension
del bpy.props.animExtension
del bpy.props.needsUpdating
del bpy.types.Scene.serverGroups
# handle the keymap
wm = bpy.context.window_manager
for km in addon_keymaps:
wm.keyconfigs.addon.keymaps.remove(km)
# clear the list
addon_keymaps.clear()
Scn = bpy.types.Scene
del bpy.props.animFrameRange
del bpy.props.imFrame
del bpy.props.animExtension
del bpy.props.nameImOutputFiles
del bpy.props.imExtension
del bpy.props.nameAveragedImage
del bpy.props.needsUpdating
del bpy.props.lastRemotePath
del Scn.offlineServers
del Scn.availableServers
del bpy.props.serverPrefs
del bpy.props.lastServerGroup
del Scn.serverGroups
del Scn.renderStatus
del Scn.renderType
del Scn.maxSamples
del Scn.samplesPerFrame
del Scn.timeout
del Scn.maxServerLoad
del Scn.nameOutputFiles
del Scn.renderDumpLoc
del Scn.tempLocalDir
del Scn.frameRanges
del Scn.compress
del Scn.killPython
del Scn.showAdvanced
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_render.remove(more_menu_options)
if __name__ == "__main__":
register()
......@@ -184,7 +184,7 @@ class sendAnimation(Operator):
def execute(self, context):
try:
self.projectName = bpy.path.display_name_from_filepath(bpy.data.filepath).replace(" ", "_")
self.projectName = bashSafeName(bpy.path.display_name_from_filepath(bpy.data.filepath))
scn = context.scene
# ensure no other render processes are running
......
......@@ -216,7 +216,7 @@ class sendFrame(Operator):
def execute(self, context):
try:
self.projectName = bpy.path.display_name_from_filepath(bpy.data.filepath).replace(" ", "_")
self.projectName = bashSafeName(bpy.path.display_name_from_filepath(bpy.data.filepath))
scn = context.scene
if scn.render.engine != "CYCLES":
......
No preview for this file type
......@@ -44,6 +44,16 @@ def have_internet():
conn.close()
return False
def bashSafeName(string):
# protects against file names that would cause problems with bash calls
if string.startswith(".") or string.startswith("-"):
string = "_" + string[1:]
# replaces problematic characters in shell with underscore '_'
chars = "!#$&'()*,;<=>?[]^`{|}~: "
for char in list(chars):
string = string.replace(char, "_")
return string
def getFrames(projectName, archiveFiles=False, frameRange=False):
""" rsync rendered frames from host server to local machine """
scn = bpy.context.scene
......@@ -296,7 +306,7 @@ def getNameOutputFiles():
scn.nameOutputFiles = scn.nameOutputFiles.replace(char, "_")
return scn.nameOutputFiles
else:
return bpy.path.display_name_from_filepath(bpy.data.filepath).replace(" ", "_")
return bashSafeName(bpy.path.display_name_from_filepath(bpy.data.filepath))
def getNumRenderedFiles(jobType, frameRange=None, fileName=None):
if jobType == "image":
......
......@@ -36,7 +36,7 @@ def bversion():
bversion = '%03d.%03d.%03d' % (bpy.app.version[0],bpy.app.version[1],bpy.app.version[2])
return bversion
def stopWatch(text, value):
def stopWatch(text, value, precision=2):
'''From seconds to Days;Hours:Minutes;Seconds'''
valueD = (((value/365)/24)/60)
......@@ -49,12 +49,10 @@ def stopWatch(text, value):
Minutes = int(valueM)
valueS = (valueM - Minutes)*60
Seconds = int(valueS)
Seconds = round(valueS, precision)
valueMs = (valueS - Seconds)*60
Miliseconds = int(valueMs)
print(str(text) + ": " + str(Days) + ";" + str(Hours) + ":" + str(Minutes) + ";" + str(Seconds) + ";;" + str(Miliseconds))
outputString = str(text) + ": " + str(Days) + ";" + str(Hours) + ":" + str(Minutes) + ";" + str(Seconds)
print(outputString)
def groupExists(groupName):
""" check if group exists in blender's memory """
......@@ -89,10 +87,12 @@ def uniquify1(seq):
keys[e] = 1
return keys.keys()
def redraw_areas(areaType="ALL"):
def redraw_areas(areaTypes=["ALL"]):
areaTypes = confirmList(areaTypes)
for area in bpy.context.screen.areas:
if areaType == "ALL" or area.type == areaType:
area.tag_redraw()
for areaType in areaTypes:
if areaType == "ALL" or area.type == areaType:
area.tag_redraw()
def disableRelationshipLines():
# disable relationship lines
......@@ -311,9 +311,9 @@ def writeErrorToFile(errorReportPath, txtName, addonVersion):
# write error to log text object
if not os.path.exists(errorReportPath):
os.makedirs(errorReportPath)
fullFilePath = os.path.join(errorReportPath, "LEGOizer_error_report.txt")
fullFilePath = os.path.join(errorReportPath, "Rebrickr_error_report.txt")
f = open(fullFilePath, "w")
f.write("\nPlease copy the following form and paste it into a new issue at https://github.com/bblanimation/legoizer/issues")
f.write("\nPlease copy the following form and paste it into a new issue at https://github.com/bblanimation/rebrickr/issues")
f.write("\n\nDon't forget to include a description of your problem! The more information you provide (what you were trying to do, what action directly preceeded the error, etc.), the easier it will be for us to squash the bug.")
f.write("\n\n### COPY EVERYTHING BELOW THIS LINE ###\n")
f.write("\nDescription of the Problem:\n")
......
import subprocess
print("running")
rub = subprocess.call("rsync --version", shell=True)
print(rub)
rub = subprocess.call("rsygc --version", shell=True)
print(rub)
......@@ -189,6 +189,10 @@ def main():
f.write(" scene.cycles.progressive = 'PATH'\n")
f.write(" scene.cycles.samples = {samples}\n".format(samples=args.samples))
f.write(" scene.cycles.use_square_samples = False\n")
f.write(" try:\n")
f.write(" scene.render.layers.active.cycles.use_denoising = False\n")
f.write(" except Exception as e:\n")
f.write(" print(e)\n")
# Print frame range to be rendered
frames = json.loads(args.frame_range)
......
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