Execute a command as a OS terminal.

        Parameters
        ----------
        *args : list of str
            Command and parameters to be executed

        Examples
        --------
        >>> DocBuilder()._run_os('python', '--version')
184921
def _run_os(*args):
        
        subprocess.check_call(args, stdout=sys.stdout, stderr=sys.stderr)
85052
def run(*argv)
      begin
        docopt_exec argv
      rescue Docopt::Exit => ex
        puts ex.message
        exit 2
      end
    end
934054
def run (cmd, verbosity=0, **kwargs):
    """"""
    # Note that shell_quote_nt() result is not suitable for copy-paste
    # (especially on Unix systems), but it looks nicer than shell_quote().
    if verbosity >= 0:
        log_info("running %s" % " ".join(map(shell_quote_nt, cmd)))
    if kwargs:
        if verbosity >= 0:
            log_info("    with %s" % ", ".join("%s=%s" % (k, shell_quote(str(v)))\
                                           for k, v in kwargs.items()))
        if kwargs.get("shell"):
            # for shell calls the command must be a string
            cmd = " ".join(cmd)
    if verbosity < 1:
        # hide command output on stdout
        with open(os.devnull, 'wb') as devnull:
            kwargs['stdout'] = devnull
            res = subprocess.call(cmd, **kwargs)
    else:
        res = subprocess.call(cmd, **kwargs)
    return res
835432
def execute(self):
        
        # Preprocess options to extract --settings and --pythonpath.
        # These options could affect the commands that are available, so they
        # must be processed early.
        parser = NewOptionParser(prog=self.prog_name,
                             usage=self.usage_info,
#                             version=self.get_version(),
                             formatter = NewFormatter(),
                             add_help_option = False,
                             option_list=self.option_list)

        options, args = parser.parse_args(self.argv)
        self.options = options
        if len(args) == 0:
            self.message("You should give at least one package name.", 'error')
            return

        subcommand = args[0]

        self.handle(args[1:], self.options, self.global_options, subcommand)
1263550
def run_command(self, args):
        
        parsed_args = self.parser.parse_args(args)
        if hasattr(parsed_args, 'func'):
            parsed_args.func(parsed_args)
        else:
            self.parser.print_help()
1142700
def run_command(args, asynchronous=False):
    """"""
    logging.info("Executing %s command %s.",
                 asynchronous and 'asynchronous' or 'synchronous', args)

    process = subprocess.Popen(args,
                               shell=True,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.STDOUT)

    try:
        timeout = asynchronous and 1 or None
        output = process.communicate(timeout=timeout)[0].decode('utf8')
    except subprocess.TimeoutExpired:
        pass

    if asynchronous:
        return PopenOutput(None, 'Asynchronous call.')
    else:
        return PopenOutput(process.returncode, output)
221046
def execute(self, *, args: Union[list, tuple], options: dict) -> tuple:
        ''''''
        cmd = self._build_cmd(args)
        process = subprocess.Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE,
                                   encoding='utf-8', shell=options.get('shell', False), env=options.get('env'))
        return process
1006778
def execute(self, *args, **kwargs):
        
        args = self.parser.parse_args(*args, **kwargs)
        self.process(args)
1331428
def run_command(self, cmd, history=True, new_prompt=True):
        """"""
        if not cmd:
            cmd = ''
        else:
            if history:
                self.add_to_history(cmd)
        if not self.multithreaded:
            if 'input' not in cmd:
                self.interpreter.stdin_write.write(
                                                to_binary_string(cmd + '\n'))
                self.interpreter.run_line()
                self.refresh.emit()
            else:
                self.write(_('In order to use commands like "raw_input" '
                             'or "input" run Spyder with the multithread '
                             'option (--multithread) from a system terminal'),
                           error=True)
        else:
            self.interpreter.stdin_write.write(to_binary_string(cmd + '\n'))
324729
def _cmd_run(cmd):
    '''
    
    '''
    cmd.insert(0, 'aptly')
    cmd_ret = __salt__['cmd.run_all'](cmd, ignore_retcode=True)

    if cmd_ret['retcode'] != 0:
        log.debug('Unable to execute command: %s\nError: %s', cmd,
                   cmd_ret['stderr'])

    return cmd_ret['stdout']
943333
def execute_command(self, cmd, params=None, callback=None, raw=False):
        '''
        
        '''
        def execute_with_callbacks(cmd, params=None, callback=None, raw=False):
            code, params = self.send_command(cmd, params, raw)
            if callback:
                callback(code, params)
            return code, params

        if self.daemon:
            t = Thread(target=execute_with_callbacks,
                    args=(cmd, ), kwargs={'params':params, 'callback':callback, 'raw':raw})
            t.daemon = True
            t.start()
        else:
            return execute_with_callbacks(cmd, params, callback, raw)
871573
def execute_command(command):
    """"""

    command = shlex.split(command)
    try:
        process = subprocess.Popen(
            command,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
    except FileNotFoundError:
        raise RuntimeError("Command not found: {}".format(repr(command)))
    process.wait()
    # TODO: may use another codec to decode
    if process.returncode > 0:
        stderr = process.stderr.read().decode("utf-8")
        raise ValueError("Error executing command: {}".format(repr(stderr)))
    return process.stdout.read().decode("utf-8")
394115
def execute(self, command):
        

        logger.info("running command %s", command)
        cmd = ["podman", "exec", self.get_id()] + command
        output = run_cmd(cmd, return_output=True)

        return output
754617
def execute_from_command_line(argv=None):
    """"""
    if sys.stdout.encoding is None:
        print('please set python env PYTHONIOENCODING=UTF-8, example: '
              'export PYTHONIOENCODING=UTF-8, when writing to stdout',
              file=sys.stderr)
        exit(1)

    command = Command(argv)
    command.execute()
436496
def run(command=None, *arguments):
    

    if command is None:
        sys.exit('django-shortcuts: No argument was supplied, please specify one.')

    if command in ALIASES:
        command = ALIASES[command]

    if command == 'startproject':
        return call('django-admin.py startproject %s' % ' '.join(arguments), shell=True)

    script_path = os.getcwd()
    while not os.path.exists(os.path.join(script_path, 'manage.py')):
        base_dir = os.path.dirname(script_path)
        if base_dir != script_path:
            script_path = base_dir
        else:
            sys.exit('django-shortcuts: No \'manage.py\' script found in this directory or its parents.')

    return call('%(python)s %(script_path)s %(command)s %(arguments)s' % {
        'python': sys.executable,
        'script_path': os.path.join(script_path, 'manage.py'),
        'command': command or '',
        'arguments': ' '.join(arguments)
    }, shell=True)
1303219
def _run_command(cmd, options=(), env=None):
    '''
    
    '''
    params = [cmd]
    params.extend(options)
    return __salt__['cmd.run_all'](params, env=env, python_shell=False)
496003
def _run_and_log(cmd, ostree_repo_path, error_msg, wd=None):
        
        logger.debug("running command %s", cmd)
        kwargs = {
            "stderr": subprocess.STDOUT,
            "env": os.environ.copy(),
        }
        if ostree_repo_path:
            # must not exist, ostree will create it
            kwargs["env"]["ATOMIC_OSTREE_REPO"] = ostree_repo_path
        if wd:
            kwargs["cwd"] = wd
        try:
            out = subprocess.check_output(cmd, **kwargs)
        except subprocess.CalledProcessError as ex:
            logger.error(ex.output)
            logger.error(error_msg)
            raise
        logger.debug("%s", out)