From 950484c00601a648b4fd49a070539b9272e2d452 Mon Sep 17 00:00:00 2001 From: Mike khiretskiy Date: Fri, 11 Apr 2014 17:35:23 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=B1=D1=89=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80=D1=8B?= =?UTF-8?q?=20=D0=B8=D0=B7=20core=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=8B?= =?UTF-8?q?=D0=B2=D0=BE=D0=B4=D0=B0=20brief?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- console/application/function.py | 131 +------------------------------- 1 file changed, 3 insertions(+), 128 deletions(-) diff --git a/console/application/function.py b/console/application/function.py index 0e6f548..77968b5 100644 --- a/console/application/function.py +++ b/console/application/function.py @@ -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: