Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/commands.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
��c@sFdZdddgZd�Zd�Zd�Zd�Zd�Zd	S(
s-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.]
tgetstatusoutputt	getoutputt	getstatuscCstdt|��S(s-Return output of "ls -ld <file>" in a string.sls -ld(Rtmkarg(tfile((s/sys/lib/python/commands.pyR!scCst|�dS(s=Return output (stdout or stderr) of executing cmd in a shell.i(R(tcmd((s/sys/lib/python/commands.pyR*scCs~ddk}|id|dd�}|i�}|i�}|djo
d}n|ddjo|d }n||fS(s4Return (status, output) of executing cmd in a shell.i�Ns{ s; } 2>&1tris
(tostpopentreadtclosetNone(RRtpipettexttsts((s/sys/lib/python/commands.pyR2scCs%ddk}t|ii||��S(Ni�(RRtpathtjoin(theadtxR((s/sys/lib/python/commands.pytmk2arg?scCsgd|jod|dSnd}x3|D]+}|djo|d}n||}q*W|d}|S(Ns's 's "s\$"`s\t"((Rtstc((s/sys/lib/python/commands.pyRKs


N(t__doc__t__all__RRRRR(((s/sys/lib/python/commands.pys<module>s				
	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.