Hi Jon,
Was too busy to get back to this for a while but I took a look at this and it does exactly what I needed, thanks!
I am running into some trouble though with another pre job script I was working on. It’s basically a job script that checks if the source file referred to in the submission parameters still exists. And if it doesn’t, the script searches through the files in that folder to try and match the naming convention. This is mostly for when people want to rename files slightly, like updating a version number, and then requeue an existing job.
Here’s what the script looks like:
[code]import re, os
from Deadline.Scripting import *
from Deadline.Jobs import *
def main( *args ):
deadlinePlugin = args[0]
job = deadlinePlugin.GetJob()
#Do a check to avoid setting a new file unless the old name is invalid
path = job.GetJobPluginInfoKeyValue("SceneFile")
if os.path.exists(path):
deadlinePlugin.LogInfo( "Scene file exists")
return
target = job.JobExtraInfo2 #This contains a scene code from Shotgun
deadlinePlugin.LogInfo( "Searching " + os.path.dirname(path) + " for " + target)
for file in os.listdir(os.path.dirname(path)):
if file[:len(target)] == target:
deadlinePlugin.LogInfo( "Found new scene file: " + os.path.join(os.path.dirname(path), file))
job.SetJobPluginInfoKeyValue("SceneFile", os.path.join(os.path.dirname(path), file))
RepositoryUtils.SaveJob( job )
return
deadlinePlugin.LogWarning( "No new scene file found, check that " + path + " is valid" )[/code]
The issue we’re having is that occasionally this will correctly find the new scene file and log that the new file has been found, but then not save the updated source information to the repository, so the job then attempts to render from a file that no longer exists. This has happened twice so far, and both times ran fine if the job was just requeued again, so I know the script works. But perhaps there’s some circumstance not being accounted for? Even if you can’t think what might be causing it, could you let me know if there’s a good way to get more info out of this and narrow down the source of the issue?
EDIT: I should have posted this log in before that the script generates:
[code]=======================================================
Log
2015-03-16 15:02:00: BEGIN - dogsmacserver.local\dogears
2015-03-16 15:02:00: 0: Start Job timeout is disabled.
2015-03-16 15:02:00: 0: Task timeout is being ignored because this is a Pre Job Script Task
2015-03-16 15:02:00: 0: Loaded job: WIP-ANIM_pr202_sc026 (54fd72471c773e5b02940ff4)
2015-03-16 15:02:00: 0: Plugin executing pre job script
2015-03-16 15:02:00: 0: Executing Pre Job Script: “/Volumes/Macintosh HD2/DeadlineRepository7/custom/scripts/Jobs/UpdateSourceFile.py”
2015-03-16 15:02:00: 0: INFO: Executing plugin script /Users/dogears/Library/Application Support/Thinkbox/Deadline7/slave/dogsmacserver/plugins/54fd72471c773e5b02940ff4/AnimeStudio.py
2015-03-16 15:02:00: 0: INFO: About: Anime Studio Plugin for Deadline
2015-03-16 15:02:00: 0: INFO: The job’s environment will be merged with the current environment before rendering
2015-03-16 15:02:00: 0: INFO: Executing pre job script /Volumes/Macintosh HD2/DeadlineRepository7/custom/scripts/Jobs/UpdateSourceFile.py
2015-03-16 15:02:00: 0: INFO: Searching /Volumes/Macintosh HD2/Puffin/12_animation/pr_202/pr202_sc026 for pr202_sc026_#####.anme
2015-03-16 15:02:00: 0: INFO: Found new scene file: /Volumes/Macintosh HD2/Puffin/12_animation/pr_202/pr202_sc026/pr202_sc026_bc.anme
=======================================================
Details
Date: 03/16/2015 15:02:00
Frames: 0
Job Submit Date: 03/09/2015 10:13:27
Job User: shotgun
Average RAM Usage: 0 (0%)
Peak RAM Usage: 0 (0%)
Average CPU Usage: 0%
Peak CPU Usage: 0%
Used CPU Clocks: 0
Total CPU Clocks: 0
=======================================================
Slave Information
Slave Name: dogsmacserver
Version: v7.0.2.3 R (24b5c0a7f)
Operating System: Mac OS X 10.8.3
Machine User: dogears
IP Address: 10.66.2.8
MAC Address: a8:86:dd:a0:24:91
CPU Architecture: x86_64
CPUs: 8
CPU Usage: 4%
Memory Usage: 4.0 GB / 4.0 GB (98%)
Free Disk Space: 872.764 GB
Video Card: Intel HD Graphics 4000
[/code]
As you can see in the log, it does find the new scene file (it changed xx.anme to bc.anme) and it doesn’t hit the end line of the script that should log when an update on the job failed. (“No new scene file found, check that " + path + " is valid”)
But when I check the submission parameters nothing has changed.