ProcessUtils.SpawnProcess - Get StandardOutput Problem

Hi all, I’m trying to write a Deadline post script that creates a mov proxy file… It’s all working well, however I’d like to add timecode from the outputed dpx files into the mov file. I can do this fine using ffmbc (a skew of ffmpeg) however in order to get the timecode from the dpx files, I need to use ImageMagick. That’s all good too, I’ve got the command to use, I can do it from within a dos window with no problems however when I try to run it from within a deadline post script I can’t capture the stdout to a variable… Here’s what I thought should work…

processDPXTimecode = ProcessUtils.SpawnProcess(imageMagickPath, imageMagickArgs) startTimecode = processDPXTimecode.StandardOutput ProcessUtils.WaitForExit( processDPXTimecode, -1 )

I’ve tried all manor of variations, changing the position of the code but I mostly get an error stating that I can’t read stdout because the process hasn’t started. Can anyone help me on this issue? As a side note, I could also write the output to a file and then read it back in, but simply putting a “>path\file.txt” inside the imageMagickArgs doesn’t actually redirect the output. Can anyone help on this issue?

Cheers, Thanks for any responses…

Adrian

Ok, So I’m replying to my own question…

For those who are interested, this is the work around…

p = Process() p.StartInfo.UseShellExecute = False p.StartInfo.RedirectStandardOutput = True p.StartInfo.FileName = imageMagickPath p.StartInfo.Arguments = imageMagickArgs p.Start() p.WaitForExit() startTimecode = p.StandardOutput.ReadToEnd()

As a side note… This whole venture shouldn’t be required… A bug I think exists, the following code should work but doesn’t…

processDPXTimecode = ProcessUtils.SpawnProcess(executable=imageMagickPath, arguments=imageMagickArgs, redirectStdOutput=True) ProcessUtils.WaitForExit( processDPXTimecode, -1 ) startTimecode = processDPXTimecode.StandardOutput.ReadToEnd()

An error is given regarding ‘redirectStdOutput’… This should be looked into.

Cheers!

Hi Adrian,

You need to use the 4th SpawnProcess function defined here:
thinkboxsoftware.com/deadlin … _Utilities

Also, I don’t think specifying the arguments as arg=value works in this case, because you’re calling .NET functions instead of native python functions.

Let us know if that helps!

  • Ryan

Hi Ryan, thanks for the response, I tried using the 4th spawnProcess function without luck… To be honest, I couldn’t work out how to instantiate a ‘ProcessWindowStyle’ object to feed it to the function… I’m not really a programmer more a guy who writes pretty complex scripts through trial and error! As a side note, the args=value proved to be fine, I could always get the process to run successfully, I just could not get the standard output of the process.

Cheers…

Adrian

P.S. I’m still convinced that ‘processDPXTimecode = ProcessUtils.SpawnProcess(executable=imageMagickPath, arguments=imageMagickArgs, redirectStdOutput=True)’ should work!

ProcessWindowStyle is a .NET enumeration from the System.Diagnostics namespace:
msdn.microsoft.com/en-us/library … style.aspx

Here is an example that should work:

from System.Diagnostics import *
from System.IO import *

...

processDPXTimecode = ProcessUtils.SpawnProcess( imageMagickPath, imageMagickArgs, Path.GetDirectoryName( imageMagickPath ), ProcessWindowStyle.Normal, True )
ProcessUtils.WaitForExit( processDPXTimecode, -1 )
startTimecode = processDPXTimecode.StandardOutput.ReadToEnd()

Hehe, then technically it wasn’t working fine. :wink:

As I mentioned previously, these are .NET functions that you are calling, not native python ones. .NET doesn’t support optional or default parameters, so I wouldn’t expect it to work when calling them from python.

Cheers,

  • Ryan