Logo Search packages:      
Sourcecode: wicd version File versions

def wicd::misc::Run (   cmd,
  include_stderr = False,
  return_pipe = False 
)

Run a command.

Runs the given command, returning either the output
of the program, or a pipe to read output from.

keyword arguments --
cmd - The command to execute
include_std_err - Boolean specifying if stderr should
                  be included in the pipe to the cmd.
return_pipe - Boolean specifying if a pipe to the
              command should be returned.  If it is
              false, all that will be returned is
              one output string from the command.

Definition at line 55 of file misc.py.

00055                                                      :
    """ Run a command.

    Runs the given command, returning either the output
    of the program, or a pipe to read output from.

    keyword arguments --
    cmd - The command to execute
    include_std_err - Boolean specifying if stderr should
                      be included in the pipe to the cmd.
    return_pipe - Boolean specifying if a pipe to the
                  command should be returned.  If it is
                  false, all that will be returned is
                  one output string from the command.

    """
    
    cmd = to_unicode(str(cmd))
    if include_stderr:
        err = STDOUT
        fds = True
    else:
        err = None
        fds = False
    tmpenv = copy(os.environ)
    tmpenv["LANG"] = "C"
    tmpenv["LC_ALL"] = "C"
    f = Popen(cmd, shell=True, stdout=PIPE, stderr=err, close_fds=fds,
              env=tmpenv)
    
    if return_pipe:
        return f.stdout
    else:
        return f.communicate()[0]
    
def LaunchAndWait(cmd):


Generated by  Doxygen 1.6.0   Back to index