Hey all,
Looks like the sys.path.insert did the trick and I need to include the Draft = reload( Draft ), but here’s the really odd thing.
When I add ClientUtils.LogText( Draft.file ) to the code that fails using sys.path.append I get this:
Appending ‘R:\Repository\Draft\Windows\64bit’ to Python search path
SysPath: ‘[‘C:\Program Files\Thinkbox\Deadline6\bin\lib’, u’R:\Repository\Draft\Windows\64bit’, ‘C:\Program Files\Thinkbox\Deadline6\bin\Dlls’, ‘C:\Program Files\Thinkbox\Deadline6\bin\python26.zip’, ‘C:\Program Files\Thinkbox\Deadline6\bin\lib\plat-win’, ‘C:\Program Files\Thinkbox\Deadline6\bin\lib\lib-tk’, ‘C:\Program Files\Thinkbox\Deadline6\bin’, ‘C:\Program Files\Thinkbox\Deadline6\bin\lib\site-packages’, ‘C:\Windows\Microsoft.NET\Framework64\v4.0.30319\’, u’C:\Program Files\Thinkbox\Deadline6\bin\UI’]’
Importing Draft to perform Thumbnail conversion…
Sucessfully imported Draft!
none
However when I use sys.path.insert I get this:
Appending ‘R:\Repository\Draft\Windows\64bit’ to Python search path
SysPath: ‘[‘C:\Program Files\Thinkbox\Deadline6\bin\lib’, u’R:\Repository\Draft\Windows\64bit’, ‘C:\Program Files\Thinkbox\Deadline6\bin\Dlls’, ‘C:\Program Files\Thinkbox\Deadline6\bin\python26.zip’, ‘C:\Program Files\Thinkbox\Deadline6\bin\lib\plat-win’, ‘C:\Program Files\Thinkbox\Deadline6\bin\lib\lib-tk’, ‘C:\Program Files\Thinkbox\Deadline6\bin’, ‘C:\Program Files\Thinkbox\Deadline6\bin\lib\site-packages’, ‘C:\Windows\Microsoft.NET\Framework64\v4.0.30319\’, u’C:\Program Files\Thinkbox\Deadline6\bin\UI’]’
Importing Draft to perform Thumbnail conversion…
Sucessfully imported Draft!
R:\Repository\Draft\Windows\64bit\Draft.pyd
I have no clue why it would say it’s been loaded when it says none is the file.
Here’s the working code:
def ConvertThumbnail( self, pathToFrame, format ):
ClientUtils.LogText( "ConvertThumbnail:" )
#first figure out where the Draft folder is on the repo
draftRepoPath = Path.Combine( RepositoryUtils.GetRootDirectory(), "Draft" )
if SystemUtils.IsRunningOnMac():
draftRepoPath = Path.Combine( draftRepoPath, "Mac" )
else:
if SystemUtils.IsRunningOnLinux():
draftRepoPath = Path.Combine( draftRepoPath, "Linux" )
else:
draftRepoPath = Path.Combine( draftRepoPath, "Windows" )
if SystemUtils.Is64Bit():
draftRepoPath = Path.Combine( draftRepoPath, "64bit" )
else:
draftRepoPath = Path.Combine( draftRepoPath, "32bit" )
#import Draft and do the actual conversion
ClientUtils.LogText( "Appending '%s' to Python search path" % draftRepoPath )
if not str(draftRepoPath) in sys.path:
sys.path.insert( 1,draftRepoPath )
ClientUtils.LogText( "SysPath: '%s'" % sys.path )
ClientUtils.LogText( "Importing Draft to perform Thumbnail conversion..." )
try:
import Draft
Draft = reload( Draft )
ClientUtils.LogText("Sucessfully imported Draft!")
ClientUtils.LogText(Draft.__file__)
except:
ClientUtils.LogText("Failed to import Draft!")
ClientUtils.LogText(traceback.format_exc())
try:
ClientUtils.LogText( "Reading in image '%s'" % pathToFrame )
originalImage = Draft.Image.ReadFromFile( str(pathToFrame) )
except:
ClientUtils.LogText("Failed to read image")
ClientUtils.LogText(traceback.format_exc())
# APPLY SRGB LUT
try:
if self.nim_encodeSRGB == "True":
displayLut = Draft.LUT.CreateSRGB()
displayLut.Apply( originalImage )
ClientUtils.LogText( 'Encoding sRGB...' )
except:
ClientUtils.LogText('Failed to Apply LUT')
ClientUtils.LogText(traceback.format_exc())
try:
ClientUtils.LogText( "Converting image to type '%s'" % format )
tempPath = Path.Combine( ClientUtils.GetDeadlineTempPath(), "%s.%s" % (Path.GetFileNameWithoutExtension(pathToFrame), format) )
ClientUtils.LogText( "Writing converted image to temp path '%s'..." % tempPath )
except:
ClientUtils.LogText('Failed to convert image.')
ClientUtils.LogText(traceback.format_exc())
try:
originalImage.WriteToFile( str(tempPath) )
ClientUtils.LogText( "Done!" )
except:
ClientUtils.LogText('Failed to write file.')
ClientUtils.LogText(traceback.format_exc())
return tempPath