Newer
Older
#!/usr/bin/env python
#coding=utf8
'''
CloudControl list command
'''
from cccli.exception import *
from sjrpc.core.exceptions import *
from cccli.printer import Printer, color
def __init__(self, cli, argv0):
self.set_usage("%prog [options] [tql]")
self.add_option("-t", action="store_true", dest="table",
help="column aligment display")
self.add_option("-l", action="store_true", dest="align",
help="line aligment display")
self.remove_option("--quiet")
self.remove_option("--direct")
self.parse_args(argv)
if len(self.args) == 0:
self.args.append("")
objs = self.rpccall("list", str.join("", self.args), _status=False, _direct=True)
if self.options.align:
elif self.options.table:
'''Listing line aligned'''
# get max size by tag
# dislay each object by line
line = str()
for (tagname,tagvalue) in o:
tagname,
self.tdc(tagname),
self.tdr(tagname, tagvalue).ljust(tags[tagname] + 1))
self.printer.out("%s%s"%(line, color["reset"]))
'''Listing table style'''
# get max size by tag
self.printer.out(t.ljust(v), nl=" ")
self.printer.out(color["reset"])
# print obj
for obj in objs:
# print others tags
self.printer.out(self.tdc(t), nl="")
self.printer.out(self.tdr(t, obj.get(t, u"")).ljust(v) ,nl=" ")
self.printer.out(color["reset"])