Beispiel #1
0
 def TablePrinter():
   """Gets a console_io.TablePrinter for printing a Component."""
   headers = (None, None, None)
   justification = (console_io.TablePrinter.JUSTIFY_LEFT,
                    console_io.TablePrinter.JUSTIFY_RIGHT,
                    console_io.TablePrinter.JUSTIFY_RIGHT)
   return console_io.TablePrinter(headers, justification=justification)
    def TablePrinter(show_versions=False):
        """Gets a console_io.TablePrinter for printing ComponentSnapshotDiffs.

    Args:
      show_versions: bool, True to display version information.  Defaults to
        False.

    Returns:
      console_io.TablePrinter: The table printer to use to print this object
      type.
    """
        if show_versions:
            headers = ('Status', 'Name', 'ID', 'Installed', 'Latest', 'Size')
            justification = (console_io.TablePrinter.JUSTIFY_LEFT,
                             console_io.TablePrinter.JUSTIFY_LEFT,
                             console_io.TablePrinter.JUSTIFY_LEFT,
                             console_io.TablePrinter.JUSTIFY_RIGHT,
                             console_io.TablePrinter.JUSTIFY_RIGHT,
                             console_io.TablePrinter.JUSTIFY_RIGHT)
        else:
            headers = ('Status', 'Name', 'ID', 'Size')
            justification = (console_io.TablePrinter.JUSTIFY_LEFT,
                             console_io.TablePrinter.JUSTIFY_LEFT,
                             console_io.TablePrinter.JUSTIFY_LEFT,
                             console_io.TablePrinter.JUSTIFY_RIGHT)
        return console_io.TablePrinter(headers, justification=justification)
Beispiel #3
0
    def Display(self, args, result):
        """This method is called to print the result of the Run() method.

    Args:
      args: The arguments that command was run with.
      result: The value returned from the Run() method.
    """
        tbl = io.TablePrinter(
            ['Name', 'ID', 'Zone', 'Nodes'],
            justification=tuple([io.TablePrinter.JUSTIFY_LEFT] * 3 +
                                [io.TablePrinter.JUSTIFY_RIGHT]))
        values = [TableValues(cluster) for cluster in result.clusters]
        tbl.Print(values)
        if not values:
            log.err.Print('0 clusters')