Ignore:
Timestamp:
Nov 28, 2008, 12:42:04 PM (16 years ago)
Author:
rybkin
Message:

See C.L. 2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tbroadcast/HEAD/python/executer.py

    r244 r478  
    209209          return 1, retVal['stdout'], retVal['stderr'], 1
    210210   
     211############################################################################     
     212def getstatusoutput(cmd):
     213    """Return (status, stdout) of executing cmd in a shell.
     214   
     215    A trailing line separator is removed from the output string. The exit status of the command is encoded in the format specified for wait(), when the exit status is zero (termination without errors), 0 is returned.
     216    """
     217    import os
     218    p = os.popen(cmd, 'r')
     219    out = p.read()
     220    sts = p.close()
     221    if sts is None: sts = 0
     222    if out.endswith(os.linesep):
     223        out = out[:out.rindex(os.linesep)]
     224    return sts, out
     225
    211226#################################################################################
    212227###################################### EoF ######################################
Note: See TracChangeset for help on using the changeset viewer.