‡Æ
ÍMö9c       s7   d  Z  d „  Z d „  Z d „  Z d „  Z d „  Z d S(   sO  Execute shell commands via os.popen() and return status, output.

Interface summary:
 
       import commands
        
       outtext = commands.getoutput(cmd)
       (exitstatus, outtext) = commands.getstatusoutput(cmd)
       outtext = commands.getstatus(file)  # returns output of "ls -ld file"

A trailing newline is removed from the output string.

Encapsulates the basic operation:
                         
      pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
      text = pipe.read()
      sts = pipe.close()

 [Note:  it would be nice to add functions to interpret the exit status.]
c    s   t  d t |  ƒ ƒ Sd S(   s-   Return output of "ls -ld <file>" in a string.s   ls -ldN(   s	   getoutputs   mkargs   file(   s   files%   /mit/python/lib/python2.0/commands.pys	   getstatus s     c    s   t  |  ƒ d Sd S(   s=   Return output (stdout or stderr) of executing cmd in a shell.i   N(   s   getstatusoutputs   cmd(   s   cmds%   /mit/python/lib/python2.0/commands.pys	   getoutput( s     c    s   d k  } | i d |  d d ƒ } | i ƒ  } | i ƒ  } | t j o
 d } n | d d j o | d  } n | | f Sd S(   s4   Return (status, output) of executing cmd in a shell.Ns   { s   ; } 2>&1s   ri    i   s   
(	   s   oss   popens   cmds   pipes   reads   texts   closes   stss   None(   s   cmds   oss   pipes   texts   stss%   /mit/python/lib/python2.0/commands.pys   getstatusoutput0 s     	 
 c    s&   d  k  } t | i i |  | ƒ ƒ Sd  S(   N(   s   oss   mkargs   paths   joins   heads   x(   s   heads   xs   oss%   /mit/python/lib/python2.0/commands.pys   mk2arg= s    	c    sm   d |  j o d |  d Sn d } x5 |  d r+ } | d j o | d } n | | } q, W| d } | Sd  S(   Ns   's    's    "i    s   \$"`s   \s   "(   s   xs   ss   c(   s   xs   ss   cs%   /mit/python/lib/python2.0/commands.pys   mkargI s    	 
N(   s   __doc__s	   getstatuss	   getoutputs   getstatusoutputs   mk2args   mkarg(    s%   /mit/python/lib/python2.0/commands.pys   ? s
   					