(program, directory=None, env_variables=None, get_output=False,
            suppress_stderr=False)
Executes an arbitrary program
Executes an arbitrary program
Executes an arbitrary program
def run(program, directory=None, env_variables=None, get_output=False,
            suppress_stderr=False):
        """Executes an arbitrary program"""
        environment = os.environ.copy()
        if env_variables is not None:
            for k,v in env_variables.items():
                environment[k] = v

        stderr = None
        if suppress_stderr:
            stderr = open(os.devnull, 'w')
        if isinstance(program, str):
            program = program.split()
        if get_output:
            output = subprocess.check_output(program,
                                             env=environment,
                                             cwd=directory,
                                             stderr=stderr)
            if suppress_stderr:
                stderr.close()
            return output.decode("ascii")
        else:
            subprocess.check_call(program, env=environment,
                                  cwd=directory, stderr=stderr)
            if suppress_stderr:
                stderr.close()
def run ( program , directory = None , env_variables = None , get_output = False , suppress_stderr = False ) : environment = os . environ . copy ( ) if env_variables is not None : for k , v in env_variables . items ( ) : environment [ k ] = v stderr = None if suppress_stderr : stderr = open ( os . devnull , 'w' ) if isinstance ( program , str ) : program = program . split ( ) if get_output : output = subprocess . check_output ( program , env = environment , cwd = directory , stderr = stderr ) if suppress_stderr : stderr . close ( ) return output . decode ( "ascii" ) else : subprocess . check_call ( program , env = environment , cwd = directory , stderr = stderr ) if suppress_stderr : stderr . close ( )