|
|
|
@ -23,6 +23,7 @@ from OpenSSL import crypto
|
|
|
|
|
import shlex
|
|
|
|
|
from sudsds import MethodNotFound
|
|
|
|
|
from calculate.core.server.cert_cmd import getHwAddr, getIpLocal
|
|
|
|
|
from calculate.core.server.replace_class import printTable
|
|
|
|
|
|
|
|
|
|
from calculate.core.client.progressbar import Bar,Percentage,ETA,ProgressBar
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
@ -213,8 +214,8 @@ def print_brief_group(Fields, group_name):
|
|
|
|
|
print_group_flag = True
|
|
|
|
|
colorPrint._printSUCCESS('%s: ' %(field.label))
|
|
|
|
|
res = printTable(data, head)
|
|
|
|
|
sys.stdout.write(res+"\n")
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
sys.stdout.write(res)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
uncompatible_count += 1
|
|
|
|
@ -254,42 +255,6 @@ def show_view(view):
|
|
|
|
|
return
|
|
|
|
|
print "+====== show view! ======+"
|
|
|
|
|
|
|
|
|
|
def printTable(data, header=None ):
|
|
|
|
|
res = []
|
|
|
|
|
for row in data:
|
|
|
|
|
encode_row = map(lambda x: x.encode('utf-8') if x else '', row)
|
|
|
|
|
res.append(encode_row)
|
|
|
|
|
data = res
|
|
|
|
|
|
|
|
|
|
if type(header) == list:
|
|
|
|
|
header = map(lambda x: x.encode('utf-8'), header)
|
|
|
|
|
|
|
|
|
|
lens = [0]*len(data[0])
|
|
|
|
|
for row in data:
|
|
|
|
|
for numCol, column in enumerate(row):
|
|
|
|
|
cLen = len(unicode(str(column).decode('utf-8')))
|
|
|
|
|
if lens[numCol] < cLen:
|
|
|
|
|
lens[numCol] = cLen
|
|
|
|
|
res = ""
|
|
|
|
|
spacer = lambda lenList: '+' + '+'.join( '-'*(x+2) for x in lenList ) + '+'
|
|
|
|
|
drawRow = lambda lenList, valueList: '|' + "".join(
|
|
|
|
|
' %s ' % item + ' ' * (lenList[num] - \
|
|
|
|
|
len(unicode(str(item).decode('utf-8')))) + '|'
|
|
|
|
|
for num, item in enumerate(valueList) )
|
|
|
|
|
if header:
|
|
|
|
|
for numCol, column in enumerate(header):
|
|
|
|
|
cLen = len(unicode(str(column).decode('utf-8')))
|
|
|
|
|
if lens[numCol] < cLen:
|
|
|
|
|
lens[numCol] = cLen
|
|
|
|
|
res += spacer(lens)+ "\n"
|
|
|
|
|
res += drawRow( lens, header )+ "\n"
|
|
|
|
|
|
|
|
|
|
res+= spacer(lens) + "\n"
|
|
|
|
|
for r in data:
|
|
|
|
|
res += drawRow( lens, r )+ "\n"
|
|
|
|
|
res+= spacer(lens)+ "\n"
|
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
def show_table(table, item):
|
|
|
|
|
if item.message:
|
|
|
|
|
colorPrint._printSUCCESS(item.message)
|
|
|
|
@ -300,8 +265,8 @@ def show_table(table, item):
|
|
|
|
|
data.append(line.string)
|
|
|
|
|
|
|
|
|
|
res = printTable(data, head)
|
|
|
|
|
sys.stdout.write(res+"\n")
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
sys.stdout.write(res)
|
|
|
|
|
|
|
|
|
|
def show_error(item):
|
|
|
|
|
if item.message:
|
|
|
|
@ -353,11 +318,13 @@ def _create_obj(client, method):
|
|
|
|
|
raise Exception(1)
|
|
|
|
|
return view_params
|
|
|
|
|
|
|
|
|
|
def get_view_params(client, method, step = None, expert = None, brief = None):
|
|
|
|
|
def get_view_params(client, method, step = None, expert = None, brief = None,
|
|
|
|
|
onlyhelp = False):
|
|
|
|
|
view_params = _create_obj(client, method)
|
|
|
|
|
view_params.step = step
|
|
|
|
|
view_params.expert = expert
|
|
|
|
|
view_params.brief = brief
|
|
|
|
|
view_params.onlyhelp = onlyhelp
|
|
|
|
|
return view_params
|
|
|
|
|
|
|
|
|
|
def callView(client, item, sid):
|
|
|
|
|