• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python format.print_list函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mysql.utilities.common.format.print_list函数的典型用法代码示例。如果您正苦于以下问题:Python print_list函数的具体用法?Python print_list怎么用?Python print_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了print_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: show_file_statistics

def show_file_statistics(file_name, wild=False, out_format="GRID"):
    """Show file statistics for file name specified

    file_name[in]    target file name and path
    wild[in]         if True, get file statistics for all files with prefix of
                     file_name. Default is False
    out_format[in]   output format to print file statistics. Default is GRID.
    """

    def _get_file_stats(path, file_name):
        """Return file stats
        """
        stats = os.stat(os.path.join(path, file_name))
        return ((file_name, stats.st_size, time.ctime(stats.st_ctime),
                 time.ctime(stats.st_mtime)))

    columns = ["File", "Size", "Created", "Last Modified"]
    rows = []
    path, filename = os.path.split(file_name)
    if wild:
        for _, _, files in os.walk(path):
            for f in files:
                if f.startswith(filename):
                    rows.append(_get_file_stats(path, f))
    else:
        rows.append(_get_file_stats(path, filename))

    print_list(sys.stdout, out_format, columns, rows)
开发者ID:fengshao0907,项目名称:mysql-utilities,代码行数:28,代码来源:tools.py


示例2: show_users

def show_users(src_val, verbosity, fmt, dump=False):
    """Show all users except root and anonymous users on the server.

    src_val[in]        a dictionary containing connection information for the
                       source including:
                       (user, password, host, port, socket)
    verbosty[in]       level of information to display
    fmt[in]            format of output
    dump[in]           if True, dump the grants for all users
                       default = False
    """
    conn_options = {"version": "5.1.0"}
    servers = connect_servers(src_val, None, conn_options)
    source = servers[0]

    if verbosity <= 1:
        _QUERY = """
            SELECT user, host FROM mysql.user
            WHERE user.user != ''
        """
        cols = ("user", "host")
    else:
        _QUERY = """
            SELECT user.user, user.host, db FROM mysql.user LEFT JOIN mysql.db
            ON user.user = db.user AND user.host = db.host
            WHERE user.user != ''
        """
        cols = ("user", "host", "database")

    users = source.exec_query(_QUERY)
    print "# All Users:"
    print_list(sys.stdout, fmt, cols, users)
    if dump:
        for user in users:
            _show_user_grants(source, None, "'%s'@'%s'" % user[0:2], verbosity)
开发者ID:cloud-dev,项目名称:mysql-utilities,代码行数:35,代码来源:userclone.py


示例3: execute

    def execute(self, connections, **kwrds):
        """Execute the search for processes, queries, or connections

        This method searches for processes, queriers, or connections to
        either kill or display the matches for one or more servers.

        connections[in]    list of connection parameters
        kwrds[in]          dictionary of options
          output           file stream to display information
                           default = sys.stdout
          connector        connector to use
                           default = mysql.connector
          format           format for display
                           default = GRID
        """

        output = kwrds.get('output', sys.stdout)
        connector = kwrds.get('connector', mysql.connector)
        fmt = kwrds.get('format', "grid")
        charset = kwrds.get('charset', None)

        headers = ("Connection", "Id", "User", "Host", "Db",
                   "Command", "Time", "State", "Info")
        entries = []
        # Build SQL statement
        for info in connections:
            conn = parse_connection(info)
            if not conn:
                msg = "'%s' is not a valid connection specifier" % (info,)
                raise FormatError(msg)
            if charset:
                conn['charset'] = charset
            info = conn
            connection = connector.connect(**info)

            if not charset:
                # If no charset provided, get it from the
                # "character_set_client" server variable.
                cursor = connection.cursor()
                cursor.execute("SHOW VARIABLES LIKE 'character_set_client'")
                res = cursor.fetchall()
                connection.set_charset_collation(charset=str(res[0][1]))
                cursor.close()

            cursor = connection.cursor()
            cursor.execute(self.__select)
            for row in cursor:
                if KILL_QUERY in self.__actions:
                    cursor.execute("KILL {0}".format(row[0]))
                if KILL_CONNECTION in self.__actions:
                    cursor.execute("KILL {0}".format(row[0]))
                if PRINT_PROCESS in self.__actions:
                    entries.append(tuple([_spec(info)] + list(row)))

        # If output is None, nothing is printed
        if len(entries) > 0 and output:
            entries.sort(key=lambda fifth: fifth[5])
            print_list(output, fmt, headers, entries)
        elif PRINT_PROCESS in self.__actions:
            raise EmptyResultError("No matches found")
开发者ID:akhan786,项目名称:LaunchDevelopment,代码行数:60,代码来源:proc.py


示例4: _get_formatted_rows

def _get_formatted_rows(rows, table, format="GRID"):
    """Get a printable representation of the data rows
    
    This method generates a formatted view of the rows from a table. The output
    format can be in one of GRID, CSV, TAB, or VERTICAL. This output is
    returned as a list of strings for use in storing the output for later
    presentation.
    
    rows[in]          missing rows
    table[in]         a Table instance of the table
    obj1_str[in]      full table name for base table
    obj2_str[in]      full table name for other table
    format[in]        format to print
    
    Returns list of formatted rows
    """
    import os
    import tempfile
    from mysql.utilities.common.format import print_list

    result_rows = []
    outfile = tempfile.TemporaryFile()
    print_list(outfile, format, table.get_col_names(), rows)
    outfile.seek(0)
    for line in outfile.readlines():
        result_rows.append(line.strip("\n"))

    return result_rows
开发者ID:dannykopping,项目名称:deploi,代码行数:28,代码来源:dbcompare.py


示例5: show_database_usage

def show_database_usage(server, datadir, dblist, options):
    """Show database usage.

    Display a list of databases and their disk space usage. The method
    accepts a list of databases to list or None or [] for all databases.

    server[in]        Connected server to operate against
    datadir[in]       The datadir for the server
    dblist[in]        List of databases
    options[in]       Required options for operation: format, no_headers,
                      verbosity, have_read, include_empty

    returns True or exception on error
    """
    
    from mysql.utilities.common.format import print_list

    format = options.get("format", "grid")
    no_headers = options.get("no_headers", False)
    verbosity = options.get("verbosity", 0)
    have_read = options.get("have_read", False)
    include_empty = options.get("do_empty", True)
    do_all = options.get("do_all", True)
    quiet = options.get("quiet", False)

    if verbosity is None:
        verbosity = 0

    locale.setlocale(locale.LC_ALL, '')

    # Check to see if we're doing all databases.
    if len(dblist) > 0:
        include_list = "("
        stop = len(dblist)
        for i in range(0,stop):
            include_list += "'%s'" % dblist[i]
            if i < stop-1:
                include_list += ", "
        include_list += ")"
        where_clause = "WHERE table_schema IN %s" % include_list
        where_clause += " AND table_schema != 'INFORMATION_SCHEMA'"
    else:
        where_clause = "WHERE table_schema != 'INFORMATION_SCHEMA'"

    res = server.exec_query(_QUERY_DBSIZE % where_clause)

    # Get list of databases with sizes and formatted when necessary
    columns, rows, db_total = _build_db_list(server, res, dblist, datadir,
                                             format == "grid",
                                             have_read, verbosity,
                                             include_empty or do_all)

    if not quiet:
        print "# Database totals:"
    print_list(sys.stdout, format, columns, rows, no_headers)
    if not quiet:
        _print_size("\nTotal database disk usage = ", db_total)
        print

    return True
开发者ID:LinhDart,项目名称:mysql-utilities,代码行数:60,代码来源:diskusage.py


示例6: show_logfile_usage

def show_logfile_usage(server, options):
    """Show log file disk space usage.

    Display log file information if logs are turned on.

    server[in]        Connected server to operate against
    datadir[in]       The datadir for the server
    options[in]       Required options for operation: format, no_headers

    return True or raise exception on error
    """
    from mysql.utilities.common.format import print_list

    format = options.get("format", "grid")
    no_headers = options.get("no_headers", False)
    verbosity = options.get("verbosity", 0)
    have_read = options.get("have_read", False)
    quiet = options.get("quiet", False)

    if not quiet:
        print "# Log information."
    total = 0
    
    _LOG_NAMES = [
        ('general_log', '_file'), ('slow_query_log', '_file'),
        ('log_error', '')
    ]
    logs = []
    for log_name in _LOG_NAMES:
        log, size = _get_log_information(server, log_name[0], log_name[1])
        if log is not None:
            logs.append((log, size))
        total += size
    
    fmt_logs = []
    columns = ['log_name', 'size']
    if len(logs) > 0:
        if format == 'grid':
            max_col = _get_formatted_max_width(logs, columns, 1)
            if max_col < len('size'):
                max_col = len('size')
            size = "{0:>{1}}".format('size', max_col)
            columns = ['log_name',size]
            for row in logs:
                # Add commas
                size = locale.format("%d", row[1], grouping=True)
                # Make justified strings
                size = "{0:>{1}}".format(size, max_col)
                fmt_logs.append((row[0], size))

        else:
            fmt_logs = logs

        print_list(sys.stdout, format, columns, fmt_logs, no_headers)
        if not quiet:
            _print_size("\nTotal size of logs = ", total)
            print

    return True
开发者ID:LinhDart,项目名称:mysql-utilities,代码行数:59,代码来源:diskusage.py


示例7: print_charsets

 def print_charsets(self):
     """Print the character set list
     """
     print_list(sys.stdout, self.format,
                ["id", "character_set_name", "collation_name",
                 "maxlen", "is_default"],
                self.charset_map)
     print len(self.charset_map), "rows in set."
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:8,代码来源:charsets.py


示例8: execute

    def execute(self, connections, output=sys.stdout,
                connector=mysql.connector, **kwrds):
        """Execute the search for objects

        This method searches for objects that match a search criteria for
        one or more servers.

        connections[in]    list of connection parameters
        output[in]         file stream to display information
                           default = sys.stdout
        connector[in]      connector to use
                           default = mysql.connector
        kwrds[in]          dictionary of options
          format           format for display
                           default = GRID
        """
        fmt = kwrds.get('format', "grid")
        charset = kwrds.get('charset', None)
        ssl_opts = kwrds.get('ssl_opts', {})
        entries = []
        for info in connections:
            conn = parse_connection(info)
            if not conn:
                msg = "'%s' is not a valid connection specifier" % (info,)
                raise FormatError(msg)
            if charset:
                conn['charset'] = charset
            info = conn
            conn['host'] = conn['host'].replace("[", "")
            conn['host'] = conn['host'].replace("]", "")

            if connector == mysql.connector:
                set_ssl_opts_in_connection_info(ssl_opts, info)

            connection = connector.connect(**info)

            if not charset:
                # If no charset provided, get it from the
                # "character_set_client" server variable.
                cursor = connection.cursor()
                cursor.execute("SHOW VARIABLES LIKE 'character_set_client'")
                res = cursor.fetchall()
                connection.set_charset_collation(charset=str(res[0][1]))
                cursor.close()

            cursor = connection.cursor()
            cursor.execute(self.__sql)
            entries.extend([tuple([_spec(info)] + list(row))
                            for row in cursor])

        headers = ["Connection"]
        headers.extend(col[0].title() for col in cursor.description)
        if len(entries) > 0 and output:
            print_list(output, fmt, headers, entries)
        else:
            msg = "Nothing matches '%s' in any %s" % \
                (self.__pattern, _join_words(self.__types, conjunction="or"))
            raise EmptyResultError(msg)
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:58,代码来源:grep.py


示例9: show_logfile_usage

def show_logfile_usage(server, options):
    """Show log file disk space usage.

    Display log file information if logs are turned on.

    server[in]        Connected server to operate against
    datadir[in]       The datadir for the server
    options[in]       Required options for operation: format, no_headers

    return True or raise exception on error
    """
    fmt = options.get("format", "grid")
    no_headers = options.get("no_headers", False)
    is_remote = options.get("is_remote", False)
    quiet = options.get("quiet", False)

    if not quiet:
        print "# Log information."
    total = 0

    _LOG_NAMES = [("general_log", "_file"), ("slow_query_log", "_file"), ("log_error", "")]
    logs = []
    for log_name in _LOG_NAMES:
        (log, size) = _get_log_information(server, log_name[0], log_name[1], is_remote)
        if log is not None:
            logs.append((log, size))
        total += size

    fmt_logs = []
    columns = ["log_name", "size"]
    if len(logs) > 0:
        if fmt == "grid":
            max_col = _get_formatted_max_width(logs, columns, 1)
            if max_col < len("size"):
                max_col = len("size")
            size = "{0:>{1}}".format("size", max_col)
            columns = ["log_name", size]
            for row in logs:
                # Add commas
                size = locale.format("%d", row[1], grouping=True)
                # Make justified strings
                size = "{0:>{1}}".format(size, max_col)
                fmt_logs.append((row[0], size))

        else:
            fmt_logs = logs

        print_list(sys.stdout, fmt, columns, fmt_logs, no_headers)
        if not quiet:
            _print_size("\nTotal size of logs = ", total)
            print

    return True
开发者ID:fengshao0907,项目名称:mysql-utilities,代码行数:53,代码来源:diskusage.py


示例10: show_topology

def show_topology(master_vals, options=None):
    """Show the slaves/topology map for a master.

    This method find the slaves attached to a server if it is a master. It
    can also discover the replication topology if the recurse option is
    True (default = False).

    It prints a tabular list of the master(s) and slaves found. If the
    show_list option is True, it will also print a list of the output
    (default = False).

    master_vals[in]    Master connection in form user:[email protected]:port:socket
                       or login-path:port:socket.
    options[in]        dictionary of options
      recurse     If True, check each slave found for additional slaves
                       Default = False
      prompt_user      If True, prompt user if slave connection fails with
                       master connection parameters
                       Default = False
      num_retries      Number of times to retry a failed connection attempt
                       Default = 0
      quiet            if True, print only the data
                       Default = False
      format           Format of list
                       Default = Grid
      width            width of report
                       Default = 75
      max_depth        maximum depth of recursive search
                       Default = None
    """
    if options is None:
        options = {}

    topo = TopologyMap(master_vals, options)
    topo.generate_topology_map(options.get('max_depth', None))

    if not options.get("quiet", False) and topo.depth():
        print "\n# Replication Topology Graph"

    if not topo.slaves_found():
        print "No slaves found."

    topo.print_graph()
    print

    if options.get("show_list", False):
        from mysql.utilities.common.format import print_list

        # make a list from the topology
        topology_list = topo.get_topology_map()
        print_list(sys.stdout, options.get("format", "GRID"),
                   ["Master", "Slave"], topology_list, False, True)
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:52,代码来源:show_rpl.py


示例11: _log_master_status

    def _log_master_status(self, master):
        """Logs the master information.

        master[in]    Master server instance.

        This method logs the master information from SHOW MASTER STATUS.
        """
        # If no master present, don't print anything.
        if master is None:
            return

        print("#")
        self._report("# {0}:".format("Current Master Information"),
                     logging.INFO)

        try:
            status = master.get_status()[0]
        except UtilError:
            msg = "Cannot get master status"
            self._report(msg, logging.ERROR, False)
            raise UtilRplError(msg)

        cols = ("Binary Log File", "Position", "Binlog_Do_DB",
                "Binlog_Ignore_DB")
        rows = (status[0] or "N/A", status[1] or "N/A", status[2] or "N/A",
                status[3] or "N/A")

        print_list(sys.stdout, self.format, cols, [rows])

        self._report("# {0}".format(
            ", ".join(["{0}: {1}".format(*item) for item in zip(cols, rows)]),
        ), logging.INFO, False)

        # Display gtid executed set
        master_gtids = []
        for gtid in status[4].split("\n"):
            if gtid:
                # Add each GTID to a tuple to match the required format to
                # print the full GRID list correctly.
                master_gtids.append((gtid.strip(","),))

        try:
            if len(master_gtids) > 1:
                gtid_executed = "{0}[...]".format(master_gtids[0][0])
            else:
                gtid_executed = master_gtids[0][0]
        except IndexError:
            gtid_executed = "None"

        self._report("# GTID Executed Set: {0}".format(gtid_executed),
                     logging.INFO)
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:51,代码来源:replication_ms.py


示例12: show_options

 def show_options(self):
     """ Show all audit log variables.
     """
     server = Server({'conn_info': self.options.get("server_vals", None)})
     server.connect()
     rows = server.show_server_variable("audit%")
     server.disconnect()
     if rows:
         print "#\n# Audit Log Variables and Options\n#"
         print_list(sys.stdout, "GRID", ['Variable_name', 'Value'],
                    rows)
         print
     else:
         raise UtilError("No audit log variables found.")
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:14,代码来源:audit_log.py


示例13: _log_data

    def _log_data(self, title, labels, data, print_format=True):
        """Helper method to log data.

        title[in]     Title to log.
        labels[in]    List of labels.
        data[in]      List of data rows.
        """
        self._report("# {0}".format(title), logging.INFO)
        for row in data:
            msg = ", ".join(
                ["{0}: {1}".format(*col) for col in zip(labels, row)]
            )
            self._report("# {0}".format(msg), logging.INFO, False)
        if print_format:
            print_list(sys.stdout, self.format, labels, data)
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:15,代码来源:replication_ms.py


示例14: __print_index_list

    def __print_index_list(indexes, fmt, no_header=False):
        """Print the list of indexes

        indexes[in]        list of indexes to print
        fmt[in]            format out output = sql, table, tab, csv
        no_header[in]      (optional) if True, do not print the header
        """
        if fmt == "sql":
            for index in indexes:
                index.print_index_sql()
        else:
            cols = ("database", "table", "name", "type", "columns")
            rows = []
            for index in indexes:
                rows.append(index.get_row())
            print_list(sys.stdout, fmt, cols, rows, no_header)
开发者ID:akhan786,项目名称:LaunchDevelopment,代码行数:16,代码来源:table.py


示例15: _print_list

    def _print_list(self, refresh=True, comment=None):
        """Display the list information

        This method displays the list information using the start_list and
        end_list member variables to control the view of the data. This
        permits users to scroll through the data should it be longer than
        the space permitted on the screen.
        """
        # If no data to print, exit
        if self.list_data is None:
            return

        if refresh:
            self.clear()
            self._print_header()
            self._print_master_status()

        # Print list name
        if comment is None:
            comment = self.comment
        print comment
        self.rows_printed += 1

        # Print the list in the remaining space
        footer_len = 2
        remaining_rows = self.max_rows - self.rows_printed - 4 - footer_len
        if len(self.list_data[1][self.start_list:self.end_list]) > \
           remaining_rows:
            rows = self.list_data[1][self.start_list:self.start_list +
                                     remaining_rows]
            self.end_list = self.start_list + remaining_rows
            self.scroll_on = True
        else:
            if len(self.list_data[1]) == self.end_list and \
               self.start_list == 0:
                self.scroll_on = False
            rows = self.list_data[1][self.start_list:self.end_list]
        if len(rows) > 0:
            self.scroll_size = len(rows)
            print_list(sys.stdout, 'GRID', self.list_data[0], rows)
            self.rows_printed += self.scroll_size + 4
        else:
            print "0 Rows Found."
            self.rows_printed += 1

        if refresh:
            self._print_footer(self.scroll_on)
开发者ID:akhan786,项目名称:LaunchDevelopment,代码行数:47,代码来源:failover_console.py


示例16: show_statistics

    def show_statistics(self):
        """Display statistical information about audit log including:
            - size, date, etc.
            - Audit log entries
        """
        out_format = self.options.get("format", "GRID")
        log_name = self.options.get("log_name", None)
        # Print file statistics:
        print "#\n# Audit Log File Statistics:\n#"
        show_file_statistics(log_name, False, out_format)

        # Print audit log 'AUDIT' entries
        print "\n#\n# Audit Log Startup Entries:\n#\n"
        cols, rows = convert_dictionary_list(self.log.header_rows)
        # Note: No need to sort rows, retrieved with the same order
        # as read (i.e., sorted by timestamp)
        print_list(sys.stdout, out_format, cols, rows)
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:17,代码来源:audit_log.py


示例17: _show_health

    def _show_health(self):
        """Run a command on a list of slaves.
        
        This method will display the replication health of the topology. This
        includes the following for each server.
        
          - host       : host name
          - port       : connection port
          - role       : "MASTER" or "SLAVE"
          - state      : UP = connected, WARN = cannot connect but can ping,
                         DOWN = cannot connect nor ping
          - gtid       : ON = gtid supported and turned on, OFF = supported
                         but not enabled, NO = not supported
          - rpl_health : (master) binlog enabled,
                         (slave) IO tread is running, SQL thread is running,
                         no errors, slave delay < max_delay,
                         read log pos + max_position < master's log position
                         Note: Will show 'ERROR' if there are multiple
                         errors encountered otherwise will display the
                         health check that failed.
        
        If verbosity is set, it will show the following additional information.
        
          (master)
            - server version, binary log file, position
           
          (slaves)
            - server version, master's binary log file, master's log position,
              IO_Thread, SQL_Thread, Secs_Behind, Remaining_Delay,
              IO_Error_Num, IO_Error
        """
        from mysql.utilities.common.format import print_list
        
        format = self.options.get("format", "grid")
        quiet = self.options.get("quiet", False)

        cols, rows = self.topology.get_health()    
    
        if not quiet:
            print "#"
            print "# Replication Topology Health:"
    
        # Print health report
        print_list(sys.stdout, format, cols, rows)
    
        return
开发者ID:dannykopping,项目名称:deploi,代码行数:46,代码来源:rpl_admin.py


示例18: execute

    def execute(self, connections, output=sys.stdout, connector=mysql.connector,
                **kwrds):
        """Execute the search for objects
        
        This method searches for objects that match a search criteria for
        one or more servers.
        
        connections[in]    list of connection parameters
        output[in]         file stream to display information
                           default = sys.stdout
        connector[in]      connector to use
                           default = mysql.connector
        kwrds[in]          dictionary of options
          format           format for display
                           default = GRID
        """
        from mysql.utilities.exception import FormatError, EmptyResultError

        format = kwrds.get('format', "grid")
        entries = []
        for info in connections:
            conn = parse_connection(info)
            if not conn:
                msg = "'%s' is not a valid connection specifier" % (info,)
                raise FormatError(msg)
            info = conn
            connection = connector.connect(**info)
            cursor = connection.cursor()
            cursor.execute(self.__sql)
            entries.extend([tuple([_spec(info)] + list(row)) for row in cursor])

        headers = ["Connection"]
        headers.extend(col[0].title() for col in cursor.description)
        if len(entries) > 0 and output:
            print_list(output, format, headers, entries)
        else:
            msg = "Nothing matches '%s' in any %s" % (self.__pattern, _join_words(self.__types, conjunction="or"))
            raise EmptyResultError(msg)
开发者ID:LinhDart,项目名称:mysql-utilities,代码行数:38,代码来源:grep.py


示例19: output_formatted_log

    def output_formatted_log(self):
        """Output the parsed log entries according to the specified format.

        Print the entries resulting from the parsing process to the standard
        output in the specified format. If no entries are found (i.e., none
        match the defined search criterion) a notification message is print.
        """
        log_rows = self.log.retrieve_rows()
        if log_rows:
            out_format = self.options.get("format", "GRID")
            if out_format == 'raw':
                for row in log_rows:
                    sys.stdout.write(row)
            else:
                # Convert the results to the appropriate format
                cols, rows = convert_dictionary_list(log_rows)
                # Note: No need to sort rows, retrieved with the same order
                # as read (i.e., sorted by timestamp)
                print_list(sys.stdout, out_format, cols, rows)
        else:
            # Print message notifying that no entry was found
            no_entry_msg = "#\n# No entry found!\n#"
            print no_entry_msg
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:23,代码来源:audit_log.py


示例20: _print_logs

def _print_logs(logs, total, options):
    """Display list of log files.

    logs[in]        List of log rows;
    total[in]       Total logs size;
    options[in]     Dictionary with the options used to print the log files,
                    namely: format, no_headers and quiet.
    """
    out_format = options.get("format", "grid")
    no_headers = options.get("no_headers", False)
    log_type = options.get("log_type", "binary log")
    quiet = options.get("quiet", False)

    columns = ["log_file"]
    fmt_logs = []
    if out_format == "GRID":
        max_col = _get_formatted_max_width(logs, ("log_file", "size"), 1)
        if max_col < len("size"):
            max_col = len("size")
        size = "{0:>{1}}".format("size", max_col)
        columns.append(size)

        for row in logs:
            # Add commas
            size = locale.format("%d", row[1], grouping=True)
            # Make justified strings
            size = "{0:>{1}}".format(size, max_col)
            fmt_logs.append((row[0], size))

    else:
        fmt_logs = logs
        columns.append("size")

    print_list(sys.stdout, out_format, columns, fmt_logs, no_headers)
    if not quiet:
        _print_size("\nTotal size of {0}s = ".format(log_type), total)
        print
开发者ID:fengshao0907,项目名称:mysql-utilities,代码行数:37,代码来源:diskusage.py



注:本文中的mysql.utilities.common.format.print_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python options.add_verbosity函数代码示例发布时间:2022-05-27
下一篇:
Python server.MySQLServer类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap