Yeah, don’t forget that Popen is expecting your command line input to be split 
into a list, with each flag and argument as an item. You can either use 
shlex.split on your raw command string (like Magno mentioned), construct your 
argument list manually, or pass shell=True to the constructor to allow your raw 
(correctly formatted) string to be passed as the command argument.

-Nathan



From: Magno Borgo 
Sent: Friday, April 13, 2012 11:00 AM
To: Nuke Python discussion 
Subject: Re: [Nuke-python] threading/subprocess help

I was just playing with something like this.
You probably need to escape the paths from your commands.

Try runnung nuke from terminal and you'll get the wrong path msg on the 
terminal.



import shlex

import re

cmd = "open " # not the space here

path= re.escape("/Applications/mocha Pro 2.6.3.app/") 

cmd += path 

subprocess.Popen(shlex.split(cmd))







  Hi Frank,

  I am trying to use this to run an external process and print th estdout to a 
nuke.display dialogue, but I keep getting:

  CRITICAL: Logging Unhandled Exception: OSError
  Traceback (most recent call last):
    File "<string>", line 23, in <module>
    File 
"/software/nuke/6.3v5/linux.centos5.x86_64/lib/python2.6/subprocess.py", line 
633, in __init__
      errread, errwrite)
    File 
"/software/nuke/6.3v5/linux.centos5.x86_64/lib/python2.6/subprocess.py", line 
1139, in _execute_child
      raise child_exception
  OSError: [Errno 2] No such file or directory


  and I have no idea what file or directory it's looking for.  Any clues?

  Even just having it as you have it exactly gives me this, am I being a bit 
literal about PIPE?



  On 9 November 2010 05:13, Frank Rueter <[email protected]> wrote:

    and as usual, just when you hit send, the answer jumps at you.
    This seems to work:

       proc = subprocess.Popen( cmd, stdout=subprocess.PIPE )
       while True:
           line = proc.stdout.readline()
           if not line: break
           print line




    On Nov 9, 2010, at 5:55 PM, Frank Rueter wrote:

    > Hi guys,
    >
    > again this is not a nuke question just a general threading/subprocess 
question:
    >
    > I am running RVIO for my publishing conversions (to create quicktimes, 
jpg proxies etc) and it all works well, except I don't get feedback from RVIO. 
So when I kick off the publish through Nuke (or whatever) I don't know what's 
happening (ie.. I can't see what RVIO is reporting back to stdout) unless I 
look at the vonerted files dropping in.
    > So, I wanna change that to eventually hook up RVIO's progress to Nuke's 
progress bar.
    >
    > I have a python method that kicks off RVIO using:
    >
    > #cmd = build the RVIO command including "-vv" or "-v" to get progress 
output to stdout
    > proc = subprocess.Popen( cmd, stdout=subprocess.PIPE)
    >
    > Since this returns a file object I then thought I can iterate through it 
like this:
    >
    > for line in proc.stdout:
    >       print line
    >
    > This does work, but RV's progress report is not printed until it's all 
done. I need it to be printed as RV reports to stdout.
    > I can see how the above can't work as expected as stdout is continuously 
written to, and I need it toread it as new info is pushed to stdout.
    >
    >
    > Does anyone know how to do this? I'm having a hard time finding the 
answer on the web.
    >
    > cheers,
    > frank_______________________________________________
    > Nuke-python mailing list
    > [email protected]
    > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

    _______________________________________________
    Nuke-python mailing list
    [email protected]
    http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python







-- 
**************************
Magno Borgo

www.borgo.tv
www.boundaryvfx.com


--------------------------------------------------------------------------------
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to