Commit 9a98ea27 authored by Christopher Gearhart's avatar Christopher Gearhart

Split buttons up into individual files

parent 40bfd273
......@@ -35,7 +35,8 @@ Created by Christopher Gearhart
import bpy
from bpy.types import Operator
from bpy.props import *
from . import (ui, buttons)
from .ui import *
from .buttons import *
from .functions.setupServers import *
def more_menu_options(self, context):
......
This diff is collapsed.
"""
Copyright (C) 2017 Bricks Brought to Life
http://bblanimation.com/
chris@bblanimation.com
Created by Christopher Gearhart
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# system imports
import bpy
import io
import json
import os
import subprocess
import time
from bpy.types import Operator
from bpy.props import *
from ..functions import *
from ..functions.averageFrames import *
from ..functions.jobIsValid import *
class editRemoteServersDict(Operator):
"""Edit the remote servers dictionary in a text editor""" # blender will use this as a tooltip for menu items and buttons.
bl_idname = "scene.edit_servers_dict" # unique identifier for buttons and menu items to reference.
bl_label = "Edit Remote Servers" # display name in the interface.
bl_options = {"REGISTER", "UNDO"} # enable undo for the operator.
def execute(self, context):
changeContext(context, "TEXT_EDITOR")
try:
libraryServersPath = os.path.join(getLibraryPath(), "servers")
bpy.ops.text.open(filepath=os.path.join(libraryServersPath, "remoteServers.txt"))
self.report({"INFO"}, "Opened 'remoteServers.txt'")
bpy.props.needsUpdating = True
except:
self.report({"ERROR"}, "ERROR: Could not open 'remoteServers.txt'. If the problem persists, try reinstalling the add-on.")
return{"FINISHED"}
"""
Copyright (C) 2017 Bricks Brought to Life
http://bblanimation.com/
chris@bblanimation.com
Created by Christopher Gearhart
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# system imports
import bpy
import io
import json
import os
import subprocess
import time
from bpy.types import Operator
from bpy.props import *
from ..functions import *
from ..functions.averageFrames import *
from ..functions.jobIsValid import *
class listMissingFrames(Operator):
"""List the output files missing from the render dump folder""" # blender will use this as a tooltip for menu items and buttons.
bl_idname = "scene.list_frames" # unique identifier for buttons and menu items to reference.
bl_label = "List Missing Frames" # display name in the interface.
bl_options = {"REGISTER", "UNDO"} # enable undo for the operator.
def execute(self, context):
scn = context.scene
# initializes self.frameRangesDict (returns False if frame range invalid)
if not setFrameRangesDict(self):
return{"FINISHED"}
# list all missing files from start frame to end frame in render dump folder
missingFrames = listMissingFiles(getNameOutputFiles(), self.frameRangesDict["string"])
if len(missingFrames) > 0:
self.report({"INFO"}, "Missing frames: {missingFrames}".format(missingFrames=missingFrames))
else:
self.report({"INFO"}, "All frames accounted for!")
return{"FINISHED"}
class setToMissingFrames(Operator):
"""Set frame range to frames missing from the render dump folder""" # blender will use this as a tooltip for menu items and buttons.
bl_idname = "scene.set_to_missing_frames" # unique identifier for buttons and menu items to reference.
bl_label = "Set to Missing Frames" # display name in the interface.
bl_options = {"REGISTER", "UNDO"} # enable undo for the operator.
def execute(self, context):
scn = context.scene
# initializes self.frameRangesDict (returns False if frame range invalid)
if not setFrameRangesDict(self):
return{"FINISHED"}
# list all missing files from start frame to end frame in render dump location
scn.frameRanges = listMissingFiles(getNameOutputFiles(), self.frameRangesDict["string"])
return{"FINISHED"}
"""
Copyright (C) 2017 Bricks Brought to Life
http://bblanimation.com/
chris@bblanimation.com
Created by Christopher Gearhart
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# system imports
import bpy
import io
import json
import os
import subprocess
import time
from bpy.types import Operator
from bpy.props import *
from ..functions import *
from ..functions.averageFrames import *
from ..functions.jobIsValid import *
class openRenderedImageInUI(Operator):
"""Open rendered image""" # blender will use this as a tooltip for menu items and buttons.
bl_idname = "scene.open_rendered_image" # unique identifier for buttons and menu items to reference.
bl_label = "Open Rendered Image" # display name in the interface.
bl_options = {"REGISTER", "UNDO"} # enable undo for the operator.
def execute(self, context):
if bpy.data.images.find(bpy.props.nameAveragedImage) >= 0:
# open rendered image in UV/Image_Editor
changeContext(context, "IMAGE_EDITOR")
for area in context.screen.areas:
if area.type == "IMAGE_EDITOR":
area.spaces.active.image = bpy.data.images[bpy.props.nameAveragedImage]
elif bpy.props.nameAveragedImage != "":
self.report({"ERROR"}, "Image could not be found: '{nameAveragedImage}'".format(nameAveragedImage=bpy.props.nameAveragedImage))
return{"CANCELLED"}
else:
self.report({"WARNING"}, "No rendered images could be found")
return{"CANCELLED"}
return{"FINISHED"}
class openRenderedAnimationInUI(Operator):
"""Open rendered animation""" # blender will use this as a tooltip for menu items and buttons.
bl_idname = "scene.open_rendered_animation" # unique identifier for buttons and menu items to reference.
bl_label = "Open Rendered Animation" # display name in the interface.
bl_options = {"REGISTER", "UNDO"} # enable undo for the operator.
def execute(self, context):
self.frameRangesDict = buildFrameRangesString(context.scene.frameRanges)
# change contexts
lastAreaType = changeContext(context, "CLIP_EDITOR")
# opens first frame of image sequence (blender imports full sequence)
openedFile = False
self.renderDumpFolder = getRenderDumpFolder()
image_sequence_filepath = "{dumpFolder}/".format(dumpFolder=self.renderDumpFolder)
for frame in bpy.props.animFrameRange:
try:
image_filename = "{fileName}_{frame}{extension}".format(fileName=getNameOutputFiles(), frame=str(frame).zfill(4), extension=bpy.props.animExtension)
bpy.ops.clip.open(directory=image_sequence_filepath, files=[{"name":image_filename}])
openedFile = image_filename
openedFrame = frame
break
except:
pass
if openedFile:
bpy.ops.clip.reload()
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=self.renderDumpFolder))
return{"FINISHED"}
"""
Copyright (C) 2017 Bricks Brought to Life
http://bblanimation.com/
chris@bblanimation.com
Created by Christopher Gearhart
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# system imports
import bpy
import io
import json
import os
import subprocess
import time
from bpy.types import Operator
from bpy.props import *
from ..functions import *
from ..functions.averageFrames import *
from ..functions.jobIsValid import *
class refreshNumAvailableServers(Operator):
"""Attempt to connect to all servers through host server""" # blender will use this as a tooltip for menu items and buttons.
bl_idname = "scene.refresh_num_available_servers" # unique identifier for buttons and menu items to reference.
bl_label = "Refresh Available Servers" # display name in the interface.
bl_options = {"REGISTER", "UNDO"} # enable undo for the operator.
def checkNumAvailServers(self):
scn = bpy.context.scene
command = "ssh -T -oStrictHostKeyChecking=no -x {login} 'python {remotePath}blender_task -H --connection_timeout {timeout} --hosts_file {remotePath}servers.txt'".format(login=bpy.props.serverPrefs["login"], remotePath=bpy.props.serverPrefs["path"], timeout=scn.timeout)
process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
return process
def updateAvailServerInfo(self):
scn = bpy.context.scene
line1 = self.process.stdout.readline().decode("ASCII").replace("\\n", "")
line2 = self.process.stdout.readline().decode("ASCII").replace("\\n", "")
available = json.loads(line1.replace("'", "\""))
offline = json.loads(line2.replace("'", "\""))
scn.availableServers = len(available)
scn.offlineServers = len(offline)
for a in bpy.context.screen.areas:
a.tag_redraw()
def modal(self, context, event):
if event.type in {"ESC"}:
self.report({"INFO"}, "Refresh process cancelled")
self.cancel(context)
return{"CANCELLED"}
if event.type == "TIMER":
self.process.poll()
# if python not found on host server
if self.process.returncode == 127 and self.state == 2:
self.report({"ERROR"}, "python not installed on host server")
self.cancel(context)
return{"CANCELLED"}
# if process finished and unknown error thrown
if self.process.returncode != 0 and self.process.returncode != None:
handleError(self, "Process {curState}".format(curState=str(self.state-1)))
self.cancel(context)
return{"CANCELLED"}
# if process finished and no errors
if self.process.returncode != None:
# print("Process {curState} finished! (return code: {returnCode})".format(curState=str(self.state-1), returnCode=str(self.process.returncode)))
# check number of available servers via host server
if self.state == 1:
bpy.props.needsUpdating = False
self.state += 1
self.process = self.checkNumAvailServers()
return{"PASS_THROUGH"}
elif self.state == 2:
self.updateAvailServerInfo()
scn = context.scene
self.report({"INFO"}, "Refresh process completed ({num} servers available)".format(num=str(scn.availableServers)))
return{"FINISHED"}
else:
self.report({"ERROR"}, "ERROR: Current state not recognized.")
return{"FINISHED"}
return{"PASS_THROUGH"}
def execute(self, context):
print("\nRunning 'checkNumAvailServers' function...")
scn = context.scene
# start initial process
self.state = 1 # initializes state for modal
if bpy.props.needsUpdating or bpy.props.lastServerGroup != scn.serverGroups:
bpy.props.lastServerGroup = scn.serverGroups
updateStatus = updateServerPrefs()
if not updateStatus["valid"]:
self.report({"ERROR"}, updateStatus["errorMessage"])
return{"CANCELLED"}
self.process = copyFiles()
bpy.props.lastRemotePath = bpy.props.serverPrefs["path"]
else:
self.process = self.checkNumAvailServers()
self.state += 1
# create timer for modal
wm = context.window_manager
self._timer = wm.event_timer_add(0.1, context.window)
wm.modal_handler_add(self)
self.report({"INFO"}, "Refreshing available servers...")
return{"RUNNING_MODAL"}
def cancel(self, context):
wm = context.window_manager
wm.event_timer_remove(self._timer)
self.process.kill()
This diff is collapsed.
This diff is collapsed.
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