Executes the command.

        :type i: cleo.inputs.input.Input
        :type o: cleo.outputs.output.Output
543997
def execute(self, i, o):
        
        super(InstallCommand, self).execute(i, o)

        database = i.get_option('database')
        repository = DatabaseMigrationRepository(self._resolver, 'migrations')

        repository.set_source(database)
        repository.create_repository()

        o.writeln('<info>Migration table created successfully</info>')
57819
def execute(self):
        
        # Ensure that we have commands registered
        if not self.commands or self._parser is None:
            raise NotImplementedError(
                "No commands registered with this program!"
            )

        # Handle input from the command line
        args = self.parser.parse_args()                # Parse the arguments

        try:

            handle_default_args(args)                  # Handle the default args

            if not hasattr(args, 'func'):              # Handle no subcommands
                self.parser.print_help()
                self.exit(0)

            msg = args.func(args)                      # Call the default function
            msg = "{}\n".format(msg) if msg else ''    # Format the message
            self.exit(0, msg)                          # Exit cleanly with message

        except Exception as e:
            if hasattr(args, 'traceback') and args.traceback:
                traceback.print_exc()

            msg = color.format(str(e), color.RED)
            self.exit(1, msg)
1049427
def run(command):
    
    p = Popen(command.split(), stdout=PIPE, stderr=PIPE)
    (stdout, stderr) = p.communicate()
    return (p.returncode, [line.strip() for line in stdout.splitlines()],
            [line.strip() for line in stderr.splitlines()])
692960
def execute(self, i, o):
        
        config = self._get_config(i)
        self._resolver = DatabaseManager(config)
488771
def execute(self, env):
        

        # parse args
        parser = self._get_parser(env)
        parsed_args, cmd_args = parser.parse_known_args(env.args)

        # disable colors
        if parsed_args.no_color:
            env.io.set_colored(False)

        # run command handler passing any remaining args
        if not parsed_args.func(env, cmd_args):
            raise HelpBanner(parser.format_help())
486692
public function execute()
    {
        $command = new \ReflectionClass($this);
        $options = input()->get();

        if (empty($options)) {
            $this->optionHelp();
        } else {

            foreach ($options as $method => $arguments) {

                if (array_key_exists('-' . $method, $this->commandOptionsShortcuts)) {
                    $method = $this->commandOptionsShortcuts[ '-' . $method ];
                }

                $optionMethod = camelcase('option-' . $method);

                if ($command->hasMethod($optionMethod)) {

                    $commandMethod = $command->getMethod($optionMethod);

                    if ($commandMethod->getNumberOfRequiredParameters() == 0) {
                        call_user_func([&$this, $optionMethod]);
                    } elseif ($commandMethod->getNumberOfRequiredParameters() > 0 and empty($arguments)) {
                        if (isset($this->commandOptions[ $method ][ 'help' ])) {
                            output()->write(
                                (new Format())
                                    ->setContextualClass(Format::INFO)
                                    ->setString(language()->getLine('CLI_USAGE') . ':')
                                    ->setNewLinesBefore(1)
                                    ->setNewLinesAfter(1)
                            );

                            output()->write(
                                (new Format())
                                    ->setContextualClass(Format::INFO)
                                    ->setString(language()->getLine($this->commandOptions[ $method ][ 'help' ]))
                                    ->setNewLinesAfter(2)
                            );
                        }
                    } else {
                        $optionArguments = is_array($arguments)
                            ? $arguments
                            : [$arguments];

                        call_user_func_array([&$this, $optionMethod], $optionArguments);
                    }
                }
            }
        }
    }
1152146
def do_execute(self):
        
        if isinstance(self.input.payload, Instances):
            inst = None
            data = self.input.payload
        else:
            inst = self.input.payload
            data = inst.dataset

        retrain = False
        if (self._header is None) or (self._header.equal_headers(data) is not None) or (inst is None):
            retrain = True
            self._header = Instances.template_instances(data, 0)

        if retrain or (self._model is None):
            cls = self.resolve_option("setup")
            if isinstance(cls, Classifier):
                self._model = Classifier.make_copy(cls)
            elif isinstance(cls, Clusterer):
                self._model = Clusterer.make_copy(cls)
            elif isinstance(cls, Associator):
                self._model = Associator.make_copy(cls)
            else:
                return "Unhandled class: " + classes.get_classname(cls)

        if retrain:
            if inst is not None:
                data = Instances.template_instances(data, 1)
                data.add_instance(inst)
            if isinstance(self._model, Classifier):
                self._model.build_classifier(data)
            elif isinstance(self._model, Clusterer):
                self._model.build_clusterer(data)
            elif isinstance(self._model, Associator):
                self._model.build_associations(data)
        else:
            if isinstance(self._model, Classifier):
                self._model.update_classifier(inst)
            elif isinstance(self._model, Clusterer):
                self._model.update_clusterer(inst)
            else:
                return "Cannot train incrementally: " + classes.get_classname(self._model)

        cont = ModelContainer(model=self._model, header=self._header)
        self._output.append(Token(cont))
        return None
39584
def run(self):
        

        async def run_command():
            try:
                self.result = self.command(
                    context=self.context,
                    **self.kwargs
                )
            except Exception as error:
                self.exception = error
                print(error)
                import traceback
                traceback.print_exc()
                import sys
                self.context.response.fail(
                    code='COMMAND_EXECUTION_ERROR',
                    message='Failed to execute command due to internal error',
                    error=error
                ).console(
                    whitespace=1
                )

        self._has_started = True
        self._loop = asyncio.new_event_loop()
        self._loop.run_until_complete(run_command())
        self._loop.close()
        self._loop = None
        self.completed_at = datetime.utcnow()
128087
def output_for(cmd, options = {})
      output = StringIO.new
      execute(cmd, options.merge(:outstream => output))
      output.string
    end
215358
def run_command(command):
    
    try:
        check_ouput = getattr(
            subprocess, 'check_output', subprocess.check_call)
        result = check_ouput(command, stderr=subprocess.STDOUT, shell=True)
        if check_ouput.__name__ == 'check_output':
            return 0, result
        else:
            return result, None
    except subprocess.CalledProcessError as e:
        return e.returncode, getattr(e, 'output', None)
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
284585
def do_execute(self):
        
        self.first_active.input = self.input
        result = self._director.execute()
        if result is None:
            self._output.append(self.input)
        return result
1171962
def execute(cls, command, shell=True):
        
        cls.debug('execute command (shell flag:%r): %r ' % (shell, command))
        try:
            check_call(command, shell=shell)
            return True
        except CalledProcessError:
            return False
721132
def execute(self, commands):
        
        try:
            commands = [i.strip() for i in commands.split(' ; ')]
        except (TypeError, AttributeError):
            pass # assume an iterable

        for command in commands:
            try:
                method, args = command.split('=', 1)
                args = tuple(CommaLexer(args))
            except (ValueError, TypeError) as exc:
                raise error.UserError("Bad command %r, probably missing a '=' (%s)" % (command, exc))

            def print_result(data):
                "Helper to print XMLRPC call results"
                args_list = ''
                if args:
                    args_list = '"' + '","'.join(args) + '"'
                print('%s\t%s\t%s=%s' % (self._fields["hash"], data, method.lstrip(':'), args_list))

            observer = print_result if method.startswith('>') else None
            method = method.lstrip('>')
            if not (method.startswith(':') or method[:2].endswith('.')):
                method = 'd.' + method
            self._make_it_so("executing command on", [method], *args, observer=observer)
1308452
def run_command(cmd):
    '''
    '''
    output = Popen(cmd,stderr=STDOUT,stdout=PIPE)
    t = output.communicate()[0],output.returncode
    output = {'message':t[0],
              'return_code':t[1]}

    return output
621160
def execute_command(self, cmd):
        
        if self.input_mode:
            self.end_input(cmd)
            return
        if cmd.endswith('\n'):
            cmd = cmd[:-1]
        # cls command
        if cmd == 'cls':
            self.clear_terminal()
            return
        self.run_command(cmd)
928736
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)
        
        if not self.global_options:
            global_options, args = parser.parse_args(self.argv)
            handle_default_options(global_options)
            args = args[1:]
        else:
            global_options = self.global_options
            args = self.argv
    
        def print_help(global_options):
            parser.print_help()
            sys.stderr.write(self.print_help_info(global_options) + '\n')
            sys.exit(0)
            
        if len(args) == 0:
            if global_options.version:
                print(self.get_version())
                sys.exit(1)
            else:
                print_help(global_options)
                sys.ext(1)
    
        try:
            subcommand = args[0]
        except IndexError:
            subcommand = 'help' # Display help if no arguments were given.
    
        if subcommand == 'help':
            if len(args) > 1:
                command = self.fetch_command(global_options, args[1])
                if issubclass(command, CommandManager):
                    cmd = command(['help'], None, '%s %s' % (self.prog_name, args[1]), global_options=global_options)
                    cmd.execute()
                else:
                    command().print_help(self.prog_name, args[1])
                sys.exit(1)
            else:
                print_help(global_options)
        if global_options.help:
            print_help(global_options)
        else:
            command = self.fetch_command(global_options, subcommand)
            if issubclass(command, CommandManager):
                cmd = command(args[1:], None, '%s %s' % (self.prog_name, subcommand), global_options=global_options)
                cmd.execute()
            else:
                cmd = command()
                cmd.run_from_argv(self.prog_name, subcommand, global_options, args[1:])