™N
äu¦9c       sL     d  Z    d „  Z ( d „  Z 0 d „  Z = d „  Z I 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,   /usr/lib/python1.5/site-packages/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,   /usr/lib/python1.5/site-packages/commands.pys	   getoutput( s   c    sŸ   0 1 2 k  } 3 | i d |  d d ƒ } 4 | i ƒ  } 5 | i ƒ  } 6 | t j o 6 d } n 7 | d d j o 7 | d  } n 8 | | f Sd S(   s4   Return (status, output) of executing cmd in a shell.s   { s   ; } 2>&1s   ri    i   s   
N(	   s   oss   popens   cmds   pipes   reads   texts   closes   stss   None(   s   cmds   oss   pipes   texts   stss,   /usr/lib/python1.5/site-packages/commands.pys   getstatusoutput0 s   	  c    s,   = > k  } ? t | i i |  | ƒ ƒ Sd  S(   N(   s   oss   mkargs   paths   joins   heads   x(   s   heads   xs   oss,   /usr/lib/python1.5/site-packages/commands.pys   mk2arg= s   	c    sŽ   I J d |  j o K d |  d Sn L d } M xA |  d M r4 } N | d j o O | d } n P | | } q; WQ | d } R | Sd  S(   Ns   's    's    "i    s   \$"`s   \s   "(   s   xs   ss   c(   s   xs   ss   cs,   /usr/lib/python1.5/site-packages/commands.pys   mkargI s   	 	N(   s   __doc__s	   getstatuss	   getoutputs   getstatusoutputs   mk2args   mkarg(    s,   /usr/lib/python1.5/site-packages/commands.pys   ? s
   	