Can you guys help me with this one? I have a event that I wrote that one of the tasks is makes a thumbnail which is based off of your shotgun code. The problem is that when I import Draft it fails and I don’t see where the problem is…
Here is the source:
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.append( str(draftRepoPath) )
#print sys.path
ClientUtils.LogText( "SysPath: '%s'" % sys.path )
ClientUtils.LogText( "Importing Draft to perform Thumbnail conversion..." )
try:
import Draft
except:
ClientUtils.LogText("Failed to import Draft!")
And Here’s the output:
Appending ‘R:\Repository\Draft\Windows\64bit’ to Python search path
SysPath: ‘[‘C:\Program Files\Thinkbox\Deadline\python\2.6.7\x64\lib’, ‘C:\Program Files\Thinkbox\Deadline\python\2.6.7\x64\Dlls’, ‘C:\Program Files\Thinkbox\Deadline\python\2.6.7\x64\python26.zip’, ‘C:\Windows\system32’, ‘C:\Program Files\Thinkbox\Deadline\bin’, ‘C:\Program Files\Thinkbox\Deadline\python\2.6.7\x64’, ‘C:\Program Files\Thinkbox\Deadline\python\2.6.7\x64\lib\site-packages’, ‘C:\Windows\Microsoft.NET\Framework64\v2.0.50727\’, ‘R:\Repository\Draft\Windows\64bit’]’
Importing Draft to perform Thumbnail conversion…
Failed to import Draft!
Is this a Python.NET script? Draft will only be loaded by Python.NET scripts because it is a cPython module. You can make your script a Python.NET script by making this your first line:
#Python.NET
Do you guys have licenses for Draft? If not, shoot an email to sales@thinkboxsoftware.com to get your licenses. A missing license will prevent the Draft module from being loaded.
Finally, it would also help to see what the actual import error is. You can do this by importing traceback:
import traceback
Then you can print out the exception in your except block:
try:
import Draft
except:
ClientUtils.LogText("Failed to import Draft!")
ClientUtils.LogText(traceback.format_exc())
Hmm, I wouldn’t think being on a network drive would be an issue, but a quick way to determine of that’s the issue is to copy Draft from the network path to a local path, and do the import from there. If that still doesn’t work, I’ll point the Draft guys at this to see if they have any ideas.
I just noticed that the R: path is still in sys.path, and it’s listed before the local path. Can you try removing the R: path from the system path to see if that makes a difference?
SysPath: '['C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\lib', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\Dlls', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\python26.zip', 'C:\\Program Files\\Thinkbox\\Deadline\\bin', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\lib\\site-packages', 'C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\', 'C:\\Program Files\\Thinkbox\\Deadline\\Draft\\Windows\\64bit']'
Importing Draft to perform Thumbnail conversion...
Failed to import Draft!
Traceback (most recent call last):
File "none", line 134, in ConvertThumbnail
ImportError: DLL load failed: The specified module could not be found.
I keep thinking I must be doing something dumb and checking it back against the shotgun example but I don’t see anywhere it’s going wrong. I even tried loading before all of my other libraries and no difference. Unfortunately I don’t have shotgun to see if that script actually works.
Thanks! I took your script, and the only change I made was the following to make it work on my end:
Commented out the first 2 lines in the init constructor.
Rename the original OnJobFinished function to OnJobFinished2.
Created a new OnJobFinished function that looked like this:
def OnJobFinished( self, job ):
outputPath = "C:\\test.png"
format = "jpeg"
try:
convertedThumb = self.ConvertThumbnail( outputPath, format )
except:
ClientUtils.LogText( "WARNING: Failed to convert frame using Draft; uploading original instead." )
I then marked the tasks for a job as complete to trigger the event, and it worked fine. The Draft module was imported, and a test.jpeg file was created.
The only other thing I can think to try is to insert the Draft path at the beginning of sys.path, instead of appending it to the end, to see if that helps.
Jon, I tried your suggestion and I’m still receiving the same error. I’m starting to think that maybe it is a problem with my last deadline repository update
It was a problem with my repository install… I was missing files in my Draft folder.
I just did a fresh install on another drive and realized I didn’t have all the files I needed. Here’s what happened when I did the Repository install and maybe this will explain it. I tried to install over our linux mounted drive from a windows box and it kept hanging and failing out. So, I downloaded the linux repository installer and installed it directly from the linux box. Repository installed no problem… But it appears there was a problem… Not sure what else would be wrong or missing but everything else seems to be working normally.
I’m glad to hear it’s working now! (Paul pointed out that my version of Draft appears to be a bit out of date, but the list was at least good enough to figure out there were missing files.)