run a given command in a single-user mode. If the command is empty - then just start and stop
975530
def single_user_mode(self, command=None, options=None):
        """"""
        cmd = [self._pgcommand('postgres'), '--single', '-D', self._data_dir]
        for opt, val in sorted((options or {}).items()):
            cmd.extend(['-c', '{0}={1}'.format(opt, val)])
        # need a database name to connect
        cmd.append(self._database)
        return self.cancellable_subprocess_call(cmd, communicate_input=command)
875319
def run(command, exit, silent, check):
    

    status = 0

    for (repo, path) in gather_repositories():
        if check and not check_repo(repo, path):
            status = 1

            if exit:
                break

            continue

        with chdir(path):
            result = subprocess.run(command, shell=True, capture_output=silent)
            if result.returncode != 0:
                status = result.returncode

                print('Command failed: {}'.format(repo))

                if exit:
                    break

    sys.exit(status)
370944
def run(cmds)
      exit_status = 0
      puts bold("[Running]\n#{cmds.gsub(/^\s*/, '   ')}")
      $stdout.flush
      #puts cmds.split(/\n */).inspect
      cmds.split(/\n */).each do |cmd|
        next if cmd.empty?
        system(cmd.to_s) unless FalkorLib.config.debug
        exit_status = $?.exitstatus
      end
      exit_status
    end
701488
def _run(self, cmd):
        '''
        
        '''

        if isinstance(cmd, six.string_types):
            cmd = salt.utils.args.shlex_split(cmd)

        try:
            log.debug(cmd)
            p = subprocess.Popen(
                cmd,
                shell=True,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE)
            return p.communicate()

        except (OSError, IOError) as exc:
            log.debug('Command Failed: %s', ' '.join(cmd))
            log.debug('Error: %s', exc)
            raise CommandExecutionError(exc)
1303219
def _run_command(cmd, options=(), env=None):
    '''
    
    '''
    params = [cmd]
    params.extend(options)
    return __salt__['cmd.run_all'](params, env=env, python_shell=False)
351674
def run_command(cmd, root, dst, input, params):
    
    use_stdout = '{output}' not in cmd
    if not use_stdout:
        params['output'] = dst
    parsed_cmd = parse_command(cmd, input=input, params=params)

    ensure_dirs(os.path.join(root, dst))

    logger.info("Running [%s] from [%s]", parsed_cmd, root)

    proc = subprocess.Popen(
        args=parsed_cmd,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        shell=True,
        cwd=root,
    )
    (stdout, stderr) = proc.communicate()

    assert not proc.returncode, stderr

    if use_stdout:
        # TODO: this should probably change dest to be a temp file
        with open(os.path.join(root, dst), 'w') as fp:
            fp.write(stdout)
523421
def _run(command, quiet=False, timeout=None):
    """"""
    try:
        with _spawn(command, quiet, timeout) as child:
            command_output = child.read().strip().replace("\r\n", "\n")
    except pexpect.TIMEOUT:
        logger.info(f"command {command} timed out")
        raise Error()

    return command_output
809465
def _run_command(self, command):
        
        try:
            my_result = call(command, shell=True)
            del my_result
        except CalledProcessError as e:
            LOGGER.exception('Running command failed %s' % command)
            message = (
                'Error while executing the following shell '
                'command: %s\nError message: %s' % (command, str(e)))
            # shameless hack - see https://github.com/AIFDR/inasafe/issues/141
            if sys.platform == 'darwin':  # Mac OS X
                if 'Errno 4' in str(e):
                    # continue as the error seems to be non critical
                    pass
                else:
                    raise Exception(message)
            else:
                raise Exception(message)
1323508
def run_command_on_agent(
        host,
        command,
        username=None,
        key_path=None,
        noisy=True
):
    

    return run_command(host, command, username, key_path, noisy)
899785
def run(self, command, opts):
        """"""
        handlers = { 
            'create': self.create,
            'delete': self.delete,
            'list': self.list
        }
        handler = handlers.get(command, None)
        if handler is None:
            error("Unrecognized command: %s" % command, 2)
        handler(opts)
1087980
def _run_cmd(cmds):
    """"""
    if not isinstance(cmds, str):
        cmds = "".join(cmds)
    print("Execute \"%s\"" % cmds)
    try:
        subprocess.check_call(cmds, shell=True)
    except subprocess.CalledProcessError as err:
        print(err)
        raise err
1136258
def run_command(cmd, env=None, max_timeout=None):
    
    arglist = cmd.split()

    output = os.tmpfile()
    try:
        pipe = Popen(arglist, stdout=output, stderr=STDOUT, env=env)
    except Exception as errmsg:
        return 1, errmsg

    # Wait only max_timeout seconds.
    if max_timeout:
        start = time.time()
        while pipe.poll() is None:
            time.sleep(0.1)
            if time.time() - start > max_timeout:
                os.kill(pipe.pid, signal.SIGINT)
                pipe.wait()
                return 1, "Time exceeded"

    pipe.wait()
    output.seek(0)
    return pipe.returncode, output.read()
937171
def run(state, command, args):
    """"""
    from ..core import do_run
    do_run(
        command=command, args=args, three=state.three, python=state.python, pypi_mirror=state.pypi_mirror
    )
1370369
def _RunCommand(self, command):
    """"""
    arguments = shlex.split(command)
    process = subprocess.Popen(
        arguments, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
        universal_newlines=True)
    if not process:
      raise RuntimeError("Running: {0:s} failed.".format(command))

    output, error = process.communicate()
    if process.returncode != 0:
      error = "\n".join(error.split("\n")[-5:])
      raise RuntimeError("Running: {0:s} failed with error:\n{1:s}.".format(
          command, error))

    return output
667712
def run_command(self, command, arg=None, is_eval=False):
        
        mode = is_eval and 'eval' or 'command'

        if isinstance(arg, tuple):
            name, d = arg
        else:
            name, d = arg, {}

        result = getattr(self.connection.admin, mode)(command, name, **d)
        return result
730759
def runCommand(command, silent=False, shell=False):
    
    splits = shlex.split(command)
    runCommandSplits(splits, silent=silent, shell=shell)
109377
def lrun(command, *args, **kwargs):
    ''''''
    return run('cd {0} && {1}'.format(ROOT, command), *args, **kwargs)