RE: error on windows with commands.getstatusoutput

Discussion in 'Python' started by Lee Harr, Dec 29, 2008.

  1. Lee Harr

    Lee Harr Guest


    >> cmd = '%s -y %s -l %s' % (conf.twistd, conf.tztac, conf.twistdlog)
    >> status, output = commands.getstatusoutput(cmd)


    > The commands module is Unix only. See its documentation :
    > http://docs.python.org/library/commands.html



    Ah. Doh!

    I was going back and forth between all of the different ways
    to do this (os.system, os.spawn*, commands.*, subprocess.*)
    and lost track of the no windows for commands thing.

    Too bad it can't raise a more meaningful error message...

    Anyhow, I've replaced it with this:


    from subprocess import Popen, PIPE, STDOUT
    p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE,
    stderr=STDOUT, close_fds=True)
    output, unused = p.communicate()
    status = p.returncode


    Does that look more windows-friendly?


    _________________________________________________________________
    Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

    http://www.microsoft.com/windows/windowslive/photos.aspx
     
    Lee Harr, Dec 29, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Carroll
    Replies:
    2
    Views:
    632
    Peter Otten
    Sep 13, 2003
  2. n.o.
    Replies:
    0
    Views:
    342
  3. Replies:
    2
    Views:
    312
  4. Lee Harr
    Replies:
    0
    Views:
    451
    Lee Harr
    Dec 28, 2008
  5. Pierre Bourdon
    Replies:
    0
    Views:
    437
    Pierre Bourdon
    Dec 28, 2008
Loading...

Share This Page