Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Made compatible with Python 3+ and formatted with pep8/black
Browse files Browse the repository at this point in the history
  • Loading branch information
gillesvink committed Jun 21, 2022
1 parent a16c968 commit aee5b3b
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 192 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,7 @@ dmypy.json
# pytype static type analyzer
.pytype/

# Project settings
.idea

# End of https://www.toptal.com/developers/gitignore/api/python
41 changes: 20 additions & 21 deletions python/tk_houdini_flipbook/create_flipbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def __init__(self, app):
self.app = app

# run a flipbook render with given settings
def runFlipbook(self, settings):
def run_flipbook(self, settings):
SceneViewer.flipbook(self.scene, settings=settings)

# get a flipbook settings object and return with given inputs
def getFlipbookSettings(self, inputSettings):
self.__getSceneViewer()
def get_flipbook_settings(self, inputSettings):
self.__get_scene_viewer()

settings = self.scene.flipbookSettings().stash()
self.app.logger.debug("Using %s object" % (settings))
Expand All @@ -58,36 +58,35 @@ def getFlipbookSettings(self, inputSettings):

return settings

def getOutputPath(self):
outputPath = {}
def get_output_path(self):
output_path = {}

# create an temporary directory for the JPG files
tempDir = tempfile.mkdtemp()
outputPath["writeTempFile"] = os.path.join(
tempDir, "temporary.$F4.jpg")
temp_dir = tempfile.mkdtemp()
output_path["writeTempFile"] = os.path.join(temp_dir, "temporary.$F4.jpg")

# format temporary path for importing in Nuke
outputPath["inputTempFile"] = re.sub(
"\$F4", "####", outputPath["writeTempFile"]
output_path["inputTempFile"] = re.sub(
"\$F4", "####", output_path["writeTempFile"]
)

# get template object from info.yml
reviewTemplate = self.app.get_template("review_file_template")
workTemplate = self.app.get_template("work_file_template")
fields = workTemplate.get_fields(hou.hipFile.path())
review_template = self.app.get_template("review_file_template")
work_template = self.app.get_template("work_file_template")
fields = work_template.get_fields(hou.hipFile.path())
self.app.logger.debug(fields)
outputPath["finFile"] = reviewTemplate.apply_fields(fields)
output_path["finFile"] = review_template.apply_fields(fields)

return outputPath
return output_path

def getFrameRange(self):
frameRange = []
def get_frame_range(self):
frame_range = []

frameRange.append(hou.hscriptExpression("$FSTART"))
frameRange.append(hou.hscriptExpression("$FEND"))
frame_range.append(hou.hscriptExpression("$FSTART"))
frame_range.append(hou.hscriptExpression("$FEND"))

return frameRange
return frame_range

def __getSceneViewer(self):
def __get_scene_viewer(self):
self.scene = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer)
self.app.logger.debug("Using panetab %s" % (self.scene))
17 changes: 10 additions & 7 deletions python/tk_houdini_flipbook/create_slate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class CreateSlate(object):
def __init__(self, app):
# initialize and set paths
self.app = app
self.nukePath = "%s" % (app.get_setting("nuke_path"))
self.nuke_path = "%s" % (app.get_setting("nuke_path"))

# set slate script path
__location__ = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(__file__))
)
self.slatePath = os.path.join(__location__, "slate.py")

def runSlate(self, inputFile, outputFile, settings):
def run_slate(self, inputFile, outputFile, settings):
# setup environment
custom_env = os.environ.copy()

Expand All @@ -60,7 +60,7 @@ def runSlate(self, inputFile, outputFile, settings):
task_name = context.step["name"]
self.app.logger.debug(task_name)
fps = hou.fps()
appPath = self.app.disk_location
app_path = self.app.disk_location

# ensure output path exists
self.app.ensure_folder_exists(os.path.dirname(os.path.abspath(outputFile)))
Expand All @@ -77,7 +77,7 @@ def runSlate(self, inputFile, outputFile, settings):
# call subprocess of nuke and convert
process = subprocess.Popen(
[
self.nukePath,
self.nuke_path,
"-t",
self.slatePath,
inputFile,
Expand All @@ -86,7 +86,7 @@ def runSlate(self, inputFile, outputFile, settings):
file_name,
str(first_frame),
str(last_frame),
appPath,
app_path,
str(version),
resolution,
user_name,
Expand All @@ -101,9 +101,12 @@ def runSlate(self, inputFile, outputFile, settings):

stdout, stderr = process.communicate()
self.app.logger.debug(stdout)

if stderr:
self.app.logger.error(stderr)

if stderr:
raise Exception("Could not correctly render file. Used Nuke version %s" % (self.nukePath))
raise Exception(
"Could not correctly render file. Used Nuke version %s"
% (self.nuke_path)
)
Loading

0 comments on commit aee5b3b

Please sign in to comment.