|
|
|
@ -21,10 +21,12 @@ import termios
|
|
|
|
|
import subprocess
|
|
|
|
|
from OpenSSL import crypto
|
|
|
|
|
import shlex
|
|
|
|
|
from calculate.core.server.func import shortTraceback
|
|
|
|
|
from calculate.lib.utils.colortext import get_terminal_print
|
|
|
|
|
from sudsds import MethodNotFound
|
|
|
|
|
from calculate.core.server.cert_cmd import getHwAddr, getIpLocal
|
|
|
|
|
from calculate.core.server.replace_class import printTable,Methods
|
|
|
|
|
from calculate.core.server.replace_class import (printTable, Methods,
|
|
|
|
|
print_brief_group)
|
|
|
|
|
|
|
|
|
|
from calculate.core.client.progressbar import Bar,Percentage,ETA,ProgressBar
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
@ -97,133 +99,6 @@ def get_ip_mac_type(client_type = None):
|
|
|
|
|
results.append ('console')
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
def print_brief_group(Fields, group_name):
|
|
|
|
|
print_group_flag = False
|
|
|
|
|
# if group_name:
|
|
|
|
|
# _print ('\b'+group_name)
|
|
|
|
|
uncompatible_count = 0
|
|
|
|
|
for field in Fields:
|
|
|
|
|
if field.uncompatible:
|
|
|
|
|
uncompatible_count += 1
|
|
|
|
|
continue
|
|
|
|
|
if field.element in ['input', 'openfile']:
|
|
|
|
|
value = field.value if field.value else ''
|
|
|
|
|
if not print_group_flag:
|
|
|
|
|
_print ('\b'+group_name)
|
|
|
|
|
print_group_flag = True
|
|
|
|
|
colorPrint._printSUCCESS('%s: %s' %(field.label, value))
|
|
|
|
|
|
|
|
|
|
elif field.element in ['combo', 'comboEdit', 'radio', 'file']:
|
|
|
|
|
if hasattr (field.comments, 'string') and field.value in \
|
|
|
|
|
field.choice.string:
|
|
|
|
|
value = map(lambda x: field.comments.string[x] \
|
|
|
|
|
if len(field.comments.string) > x \
|
|
|
|
|
else field.choice.string[x],
|
|
|
|
|
map(lambda x: field.choice.string.index(x), \
|
|
|
|
|
[field.value]))
|
|
|
|
|
value = ', '.join(value)
|
|
|
|
|
else:
|
|
|
|
|
value = field.value if field.value else ''
|
|
|
|
|
if not print_group_flag:
|
|
|
|
|
_print ('\b'+group_name)
|
|
|
|
|
print_group_flag = True
|
|
|
|
|
colorPrint._printSUCCESS('%s: %s' %(field.label, value))
|
|
|
|
|
|
|
|
|
|
elif field.element in ['multichoice', 'multichoice_add',\
|
|
|
|
|
'selecttable', 'selecttable_add']:
|
|
|
|
|
if hasattr (field.comments, 'string') and \
|
|
|
|
|
hasattr (field.listvalue, 'string'):
|
|
|
|
|
value = map(lambda x: field.comments.string[x] \
|
|
|
|
|
if len(field.comments.string) > x \
|
|
|
|
|
else field.choice.string[x],
|
|
|
|
|
map(lambda x: field.choice.string.index(x), \
|
|
|
|
|
field.listvalue.string))
|
|
|
|
|
value = ', '.join(value)
|
|
|
|
|
elif hasattr (field.listvalue, 'string'):
|
|
|
|
|
value = ', '.join(field.listvalue.string)
|
|
|
|
|
else:
|
|
|
|
|
value = field.value if field.value else ''
|
|
|
|
|
if not print_group_flag:
|
|
|
|
|
_print ('\b'+group_name)
|
|
|
|
|
print_group_flag = True
|
|
|
|
|
colorPrint._printSUCCESS('%s: %s' %(field.label, value))
|
|
|
|
|
|
|
|
|
|
# elif field.element == 'label':
|
|
|
|
|
# print field.label
|
|
|
|
|
|
|
|
|
|
elif field.element == 'error':
|
|
|
|
|
if not print_group_flag:
|
|
|
|
|
_print ('\b'+group_name)
|
|
|
|
|
print_group_flag = True
|
|
|
|
|
colorPrint.printERROR(field.label)
|
|
|
|
|
|
|
|
|
|
elif field.element in ['check', 'check_tristate']:
|
|
|
|
|
if field.value == 'on':
|
|
|
|
|
value = _('yes')
|
|
|
|
|
elif field.value == 'off':
|
|
|
|
|
value = _('no')
|
|
|
|
|
elif field.value == 'auto':
|
|
|
|
|
value = _('auto')
|
|
|
|
|
else:
|
|
|
|
|
value = field.value
|
|
|
|
|
if not print_group_flag:
|
|
|
|
|
_print ('\b'+group_name)
|
|
|
|
|
print_group_flag = True
|
|
|
|
|
colorPrint._printSUCCESS('%s: %s' %(field.label, value))
|
|
|
|
|
|
|
|
|
|
elif field.element == 'table' and field.type != 'steps':
|
|
|
|
|
if hasattr (field.tablevalue.head, 'string'):
|
|
|
|
|
head = field.tablevalue.head.string
|
|
|
|
|
else: head = None
|
|
|
|
|
|
|
|
|
|
body = []
|
|
|
|
|
if hasattr (field.tablevalue.body, 'stringArray'):
|
|
|
|
|
for row in field.tablevalue.body.stringArray:
|
|
|
|
|
if hasattr(row, 'string'):
|
|
|
|
|
body.append(row.string)
|
|
|
|
|
else: body = [[]]
|
|
|
|
|
|
|
|
|
|
# if empty table
|
|
|
|
|
if not filter (None, map(lambda x: x, body)):
|
|
|
|
|
body = [['']*len(head)]
|
|
|
|
|
res = printTable(body, head)
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
sys.stdout.write(res)
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
ChoiceValue = field.tablevalue.values.ChoiceValue
|
|
|
|
|
for row in xrange(len(ChoiceValue)):
|
|
|
|
|
if ChoiceValue[row].typefield in ['check', 'check_tristate']:
|
|
|
|
|
for i in xrange(len(body)):
|
|
|
|
|
if body[i][row] == 'on':
|
|
|
|
|
body[i][row] = _('yes')
|
|
|
|
|
if body[i][row] == 'off':
|
|
|
|
|
body[i][row] = _('no')
|
|
|
|
|
if body[i][row] == 'auto':
|
|
|
|
|
body[i][row] = _('auto')
|
|
|
|
|
if ChoiceValue[row].typefield == 'password':
|
|
|
|
|
for i in xrange(len(body)):
|
|
|
|
|
if body[i][row]:
|
|
|
|
|
body[i][row] = '***'
|
|
|
|
|
|
|
|
|
|
data = []
|
|
|
|
|
for body_row in body:
|
|
|
|
|
data.append(map(lambda x: x if x else '', body_row))
|
|
|
|
|
|
|
|
|
|
if not print_group_flag:
|
|
|
|
|
_print ('\b'+group_name)
|
|
|
|
|
print_group_flag = True
|
|
|
|
|
colorPrint._printSUCCESS('%s: ' %(field.label))
|
|
|
|
|
res = printTable(data, head)
|
|
|
|
|
sys.stdout.write(res+"\n")
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
uncompatible_count += 1
|
|
|
|
|
|
|
|
|
|
# if uncompatible_count == len (Fields) and group_name:
|
|
|
|
|
# colorPrint._printSUCCESS(_('Not used'))
|
|
|
|
|
|
|
|
|
|
def print_brief(view, brief_label):
|
|
|
|
|
for Group in view.groups.GroupField:
|
|
|
|
|
if Group.name:
|
|
|
|
|