Пример #1
0
    def load_services(self, options, config):
        """Load services into each protocol server.

        :param options: The options for the commands that shall be
                        created.
        :param config: The configuration for the commands that shall
                       be created.
        """
        _LOGGER.info("Loading Services.")

        find_commands(config)

        for group_name in get_groups():
            for command_name in get_commands(group_name):
                command = get_command(group_name, command_name)
                if hasattr(command, "execute"):
                    _LOGGER.debug(
                        "Registering %s.", command.group_name + '.' + \
                        command.command_name
                        )
                    if self.__mysql_server:
                        cmd = command()
                        cmd.setup_server(self.__mysql_server, options, config)
                        self.__mysql_server.register_command(cmd)

                    if self.__rpc_server:
                        cmd = command()
                        cmd.setup_server(self.__rpc_server, options, config)
                        self.__rpc_server.register_command(cmd)
Пример #2
0
    def load_services(self, options, config):
        """Load services into each protocol server.

        :param options: The options for the commands that shall be
                        created.
        :param config: The configuration for the commands that shall
                       be created.
        """
        _LOGGER.info("Loading Services.")

        find_commands(config)

        for group_name in get_groups():
            for command_name in get_commands(group_name):
                command = get_command(group_name, command_name)
                if hasattr(command, "execute"):
                    _LOGGER.debug(
                        "Registering %s.", command.group_name + '.' + \
                        command.command_name
                        )
                    if self.__mysql_server:
                        cmd = command()
                        cmd.setup_server(self.__mysql_server, options, config)
                        self.__mysql_server.register_command(cmd)

                    if self.__rpc_server:
                        cmd = command()
                        cmd.setup_server(self.__rpc_server, options, config)
                        self.__rpc_server.register_command(cmd)
Пример #3
0
def show_commands():
    """List the possible commands and their descriptions.

    """

    commands = []
    max_name_size = 0

    for group_name in get_groups():
        for command_name in get_commands(group_name):
            cls = get_command(group_name, command_name)

            doc_text = ""
            if cls.__doc__ and cls.__doc__.find(".") != -1:
                doc_text = cls.__doc__[0:cls.__doc__.find(".") + 1]
            elif cls.__doc__:
                doc_text = cls.__doc__
            doc_text = [text.strip(" ") for text in doc_text.split("\n")]

            commands.append((group_name, command_name, " ".join(doc_text)))

            name_size = len(group_name) + len(command_name)
            if name_size > max_name_size:
                max_name_size = name_size

    # Format each description and print the result.
    wrapper = textwrap.TextWrapper(subsequent_indent=(" " *
                                                      (max_name_size + 3)))
    for group_name, command_name, help_text in commands:
        padding_size = max_name_size - len(group_name) - len(command_name)
        padding_size = 0 if padding_size < 0 else padding_size
        padding_text = "".rjust(padding_size, " ")
        help_text = wrapper.fill(help_text)
        text = (group_name, command_name, padding_text, help_text)
        print " ".join(text)
Пример #4
0
def show_groups():
    """List groups that have been registered.

    This function list all groups that have been used anywhere when
    registering commands.

    """

    print "Available groups:", ", ".join(group for group in get_groups())
Пример #5
0
def show_groups():
    """List groups that have been registered.

    This function list all groups that have been used anywhere when
    registering commands.

    """

    print "Available groups:", ", ".join(group for group in get_groups())
Пример #6
0
    def _handle_information_schema_routines(self, is_routines_match):
        """Handle a select from INFORMATION_SCHEMA.ROUTINES

        We give a list of all groups and commands. There is no filtering
        going on.

        :param is_routines_match:
        :return:
        """

        groups = get_groups()

        self.send_packet(self.column_count_packet(5))
        self.send_packet(self.column_packet(
            'SPECIFIC_NAME',
            type_=str,
            table='routines',
            catalog='information_schema'
        ))
        self.send_packet(self.column_packet(
            'ROUTINE_CATALOG',
            type_=str,
            table='routines',
            catalog='information_schema'
        ))
        self.send_packet(self.column_packet(
            'ROUTINE_SCHEMA',
            type_=str,
            table='routines',
            catalog='information_schema'
        ))
        self.send_packet(self.column_packet(
            'ROUTINE_NAME',
            type_=str,
            table='routines',
            catalog='information_schema'
        ))
        self.send_packet(self.column_packet(
            'ROUTINE_TYPE',
            type_=str,
            table='routines',
            catalog='information_schema'
        ))
        self.send_packet(self.eof_packet())

        for group in groups:
            commands = get_commands(group)
            for command in commands:
                self.send_packet(self.row_packet(
                    '{0}.{1}'.format(group, command),  # specific_name
                    'fabric',  # catalog
                    group,  # routine_schema
                    command,  # routine_name
                    'FABRIC_COMMAND',  # routine_type
                    ))
        self.send_packet(self.eof_packet())
Пример #7
0
def show_commands():
    """List the possible commands and their descriptions.

    """

    commands = []
    max_name_size = 0

    for group_name in get_groups():
        for command_name in get_commands(group_name):
            cls = get_command(group_name, command_name)

            doc_text = ""
            if cls.__doc__ and cls.__doc__.find(".") != -1:
                doc_text = cls.__doc__[0: cls.__doc__.find(".") + 1]
            elif cls.__doc__:
                doc_text = cls.__doc__
            doc_text = [text.strip(" ") for text in doc_text.split("\n")]

            commands.append(
                (group_name, command_name, " ".join(doc_text))
            )

            name_size = len(group_name) + len(command_name)
            if name_size > max_name_size:
                max_name_size = name_size

    # Format each description and print the result.
    wrapper = textwrap.TextWrapper(
        subsequent_indent=(" " * (max_name_size + 3)))
    for group_name, command_name, help_text in commands:
        padding_size = max_name_size - len(group_name) - len(command_name)
        padding_size = 0 if padding_size < 0 else padding_size
        padding_text = "".rjust(padding_size, " ")
        help_text = wrapper.fill(help_text)
        text = (group_name, command_name, padding_text, help_text)
        print " ".join(text)