parent
8158588dbd
commit
8a9a53acbe
@ -0,0 +1,152 @@
|
||||
diff --git console/application/function.py console/application/function.py
|
||||
index 0e6f548..77968b5 100644
|
||||
--- console/application/function.py
|
||||
+++ 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:
|
@ -0,0 +1,51 @@
|
||||
# Copyright 1999-2012 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: $
|
||||
|
||||
EAPI="3"
|
||||
SUPPORT_PYTHON_ABIS="1"
|
||||
PYTHON_DEPEND="2:2.7"
|
||||
RESTRICT_PYTHON_ABIS="2.4 2.5 2.6 3.*"
|
||||
|
||||
inherit distutils eutils
|
||||
|
||||
SRC_URI="ftp://ftp.calculate.ru/pub/calculate/calculate3/${PN}/${P}.tar.bz2"
|
||||
|
||||
DESCRIPTION="The WSDL core for Calculate 3"
|
||||
HOMEPAGE="http://www.calculate-linux.org/main/en/calculate2"
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="3"
|
||||
KEYWORDS="amd64 x86"
|
||||
IUSE="minimal"
|
||||
|
||||
DEPEND="~sys-apps/calculate-lib-3.2.0_alpha4
|
||||
>=dev-python/soaplib-1.0
|
||||
!minimal? ( dev-python/sudsds
|
||||
net-libs/dslib
|
||||
dev-python/pyopenssl
|
||||
dev-libs/openssl
|
||||
dev-python/m2crypto
|
||||
dev-python/cherrypy )"
|
||||
RDEPEND="${DEPEND}"
|
||||
|
||||
pkg_preinst() {
|
||||
dosym /usr/sbin/cl-core /usr/sbin/cl-core-setup
|
||||
dosym /usr/sbin/cl-core /usr/sbin/cl-core-patch
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
einfo "For autoconfigure calculate-core for adminuser perform:"
|
||||
einfo " cl-core --bootstrap <username>"
|
||||
einfo "For run calculate-core perform:"
|
||||
einfo " /etc/init.d/calculate-core start"
|
||||
einfo "Add calcualte core to autorun:"
|
||||
einfo " rc-update add calculate-core boot"
|
||||
}
|
||||
|
||||
src_unpack() {
|
||||
unpack "${A}"
|
||||
cd "${S}"
|
||||
|
||||
# apply revision changes
|
||||
epatch "${FILESDIR}/calculate-core-3.2.0_alpha4-r1.patch"
|
||||
}
|
@ -0,0 +1,453 @@
|
||||
diff --git core/server/api_types.py core/server/api_types.py
|
||||
index 3863d53..eb205c1 100644
|
||||
--- core/server/api_types.py
|
||||
+++ core/server/api_types.py
|
||||
@@ -164,6 +164,97 @@ class Table(DataVarsSerializer):
|
||||
self.onClick = onClick
|
||||
self.addAction = addAction
|
||||
|
||||
+class ChoiceValueAdapter(object):
|
||||
+ def __init__(self, choicevalue):
|
||||
+ self.choicevalue = choicevalue
|
||||
+
|
||||
+ @property
|
||||
+ def values(self):
|
||||
+ return self.choicevalue.values.string
|
||||
+
|
||||
+ @property
|
||||
+ def comments(self):
|
||||
+ return self.choicevalue.comments.string
|
||||
+
|
||||
+ @property
|
||||
+ def onChanged(self):
|
||||
+ return self.choicevalue.onChanged.string
|
||||
+
|
||||
+ def __getattr__(self, item):
|
||||
+ return getattr(self.choicevalue, item)
|
||||
+
|
||||
+ @classmethod
|
||||
+ def from_detect(cls, choicevalue):
|
||||
+ if isinstance(choicevalue, ChoiceValue):
|
||||
+ return choicevalue
|
||||
+ else:
|
||||
+ return cls(choicevalue)
|
||||
+
|
||||
+class TableAdapter(object):
|
||||
+ def __init__(self, table):
|
||||
+ self.table = table
|
||||
+
|
||||
+ @property
|
||||
+ def fields(self):
|
||||
+ return self.table.fields.string
|
||||
+
|
||||
+ @property
|
||||
+ def head(self):
|
||||
+ return self.table.head.string
|
||||
+
|
||||
+ @property
|
||||
+ def body(self):
|
||||
+ if hasattr(self.table.body,'stringArray'):
|
||||
+ return [row.string
|
||||
+ for row in self.table.body.stringArray
|
||||
+ if hasattr(row, "string")]
|
||||
+ return []
|
||||
+
|
||||
+ @property
|
||||
+ def values(self):
|
||||
+ return [ChoiceValueAdapter(x) for x in self.table.values.ChoiceValue]
|
||||
+
|
||||
+ def __getattr__(self, item):
|
||||
+ return getattr(self.table, item)
|
||||
+
|
||||
+ @classmethod
|
||||
+ def from_detect(cls, table):
|
||||
+ if isinstance(table, Table):
|
||||
+ return table
|
||||
+ else:
|
||||
+ return cls(table)
|
||||
+
|
||||
+class FieldAdapter(object):
|
||||
+ def __init__(self, field):
|
||||
+ self.field = field
|
||||
+
|
||||
+ @property
|
||||
+ def choice(self):
|
||||
+ return self.field.choice.string
|
||||
+
|
||||
+ @property
|
||||
+ def listvalue(self):
|
||||
+ return self.field.listvalue.string
|
||||
+
|
||||
+ @property
|
||||
+ def comments(self):
|
||||
+ return self.field.comments.string
|
||||
+
|
||||
+ @property
|
||||
+ def tablevalue(self):
|
||||
+ return TableAdapter(self.field.tablevalue)
|
||||
+
|
||||
+ def __getattr__(self, item):
|
||||
+ return getattr(self.field, item)
|
||||
+
|
||||
+ @classmethod
|
||||
+ def from_detect(cls, field):
|
||||
+ if isinstance(field, Field):
|
||||
+ return field
|
||||
+ else:
|
||||
+ return cls(field)
|
||||
+
|
||||
+
|
||||
class Option(DataVarsSerializer):
|
||||
shortopt = String
|
||||
longopt = String
|
||||
diff --git core/server/replace_class.py core/server/replace_class.py
|
||||
index 23c5282..d01dd9b 100644
|
||||
--- core/server/replace_class.py
|
||||
+++ core/server/replace_class.py
|
||||
@@ -34,6 +34,7 @@ from calculate.lib.utils.colortext.output import BaseOutput
|
||||
from calculate.lib.cl_print import color_print
|
||||
from calculate.lib.datavars import VariableError
|
||||
from calculate.lib.cl_lang import setLocalTranslate
|
||||
+from calculate.core.server.api_types import FieldAdapter
|
||||
|
||||
from methods_func import get_method_argparser, collect_object, \
|
||||
check_result_msg, get_param_pwd, _print
|
||||
@@ -44,7 +45,7 @@ from func import shortTraceback, CommonMethods
|
||||
|
||||
|
||||
setLocalTranslate('cl_core3', sys.modules[__name__])
|
||||
-from itertools import cycle
|
||||
+from itertools import cycle, izip, ifilter
|
||||
import time
|
||||
|
||||
|
||||
@@ -766,159 +767,176 @@ def print_brief(view, brief_label):
|
||||
print_brief_group(Group.fields, Group.name)
|
||||
|
||||
|
||||
-def print_brief_group(Fields, group_name):
|
||||
- print_group_flag = False
|
||||
- # if group_name:
|
||||
- # _print ('\b'+group_name)
|
||||
- uncompatible_count = 0
|
||||
- colorPrint = color_print()
|
||||
- _colorprint = get_terminal_print(_print)
|
||||
- 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:
|
||||
- if group_name:
|
||||
- print_group_flag = True
|
||||
- _colorprint.bold.foreground(
|
||||
- TextState.Colors.WHITE)(group_name)
|
||||
- colorPrint.printSUCCESS('%s: %s' % (field.label, value))
|
||||
-
|
||||
- elif field.element in ['combo', 'comboEdit', 'radio', 'file']:
|
||||
- if field.choice:
|
||||
- if not field.choice[0]:
|
||||
- field.choice.pop(0)
|
||||
- if field.comments:
|
||||
- if not field.comments[0]:
|
||||
- field.comments.pop(0)
|
||||
- if field.comments and field.choice:
|
||||
- if not field.value in field.choice:
|
||||
- field.choice.append(field.value)
|
||||
- value = map(lambda x: field.comments[x] \
|
||||
- if len(field.comments) > x else field.choice[x],
|
||||
- map(lambda x: field.choice.index(x),
|
||||
- filter(lambda x: x in field.choice,
|
||||
- [field.value])))
|
||||
- value = ', '.join(value)
|
||||
- else:
|
||||
- value = field.value if field.value else ''
|
||||
- if not print_group_flag:
|
||||
- if group_name:
|
||||
- print_group_flag = True
|
||||
- #_print('\b' + group_name)
|
||||
- _colorprint.bold.foreground(
|
||||
- TextState.Colors.WHITE)(group_name)
|
||||
- colorPrint.printSUCCESS('%s: %s' % (field.label, value))
|
||||
-
|
||||
- elif field.element in ['multichoice', 'multichoice_add', \
|
||||
- 'selecttable', 'selecttable_add']:
|
||||
- if field.choice:
|
||||
- if not field.choice[0]:
|
||||
- field.choice.pop(0)
|
||||
- if field.comments:
|
||||
- if not field.comments[0]:
|
||||
- field.comments.pop(0)
|
||||
- if field.listvalue:
|
||||
- if not field.listvalue[0]:
|
||||
- field.listvalue.pop(0)
|
||||
- if field.choice:
|
||||
- value = map(lambda x: field.comments[x] \
|
||||
- if len(field.comments) > x \
|
||||
- else field.choice[x],
|
||||
- map(lambda x: field.choice.index(x), \
|
||||
- field.listvalue))
|
||||
+class Display(object):
|
||||
+ def __init__(self):
|
||||
+ self._print = get_terminal_print(color_print().defaultPrint)
|
||||
+
|
||||
+ def print_info(self, label, value):
|
||||
+ GREEN = TextState.Colors.GREEN
|
||||
+ self.display_asterisk(GREEN)
|
||||
+ self._print("%s: " % label)
|
||||
+ WHITE = TextState.Colors.WHITE
|
||||
+ self._print.foreground(WHITE)(value)
|
||||
+ self._print("\n")
|
||||
+
|
||||
+ def print_label(self, label):
|
||||
+ GREEN = TextState.Colors.GREEN
|
||||
+ self.display_asterisk(GREEN)
|
||||
+ self._print("%s: " % label)
|
||||
+ self._print("\n")
|
||||
+
|
||||
+ def display_asterisk(self, color):
|
||||
+ self._print(" ")
|
||||
+ self._print.foreground(color).bold("*")
|
||||
+ self._print(" ")
|
||||
+
|
||||
+ def print_error(self, message):
|
||||
+ RED = TextState.Colors.RED
|
||||
+ self.display_asterisk(RED)
|
||||
+ self._print(message)
|
||||
+ self._print("\n")
|
||||
+
|
||||
+ def print_table(self, data, head):
|
||||
+ sys.stdout.write('%s\n' % printTable(data, head))
|
||||
+
|
||||
+ def print_group(self, label):
|
||||
+ WHITE = TextState.Colors.WHITE
|
||||
+ self._print.foreground(WHITE).bold(label)
|
||||
+ self._print("\n")
|
||||
+
|
||||
+
|
||||
+class InformationElement(object):
|
||||
+ def __init__(self, field, display):
|
||||
+ self.value = ""
|
||||
+ self.label = ""
|
||||
+ self.display = display
|
||||
+
|
||||
+ @classmethod
|
||||
+ def from_field(cls, field, display):
|
||||
+ if field.type == 'steps':
|
||||
+ return None
|
||||
+ map_elements = {'input': ValueInfo,
|
||||
+ 'openfile': ValueInfo,
|
||||
+ 'combo': ChoiceInfo,
|
||||
+ 'comboEdit': ChoiceInfo,
|
||||
+ 'radio': ChoiceInfo,
|
||||
+ 'file': ChoiceInfo,
|
||||
+ 'multichoice': MultiChoiceInfo,
|
||||
+ 'multichoice_add': MultiChoiceInfo,
|
||||
+ 'selecttable': MultiChoiceInfo,
|
||||
+ 'selecttable_add': MultiChoiceInfo,
|
||||
+ 'error': ErrorInfo,
|
||||
+ 'check': CheckInfo,
|
||||
+ 'check_tristate': CheckInfo,
|
||||
+ 'table': TableInfo
|
||||
+ }
|
||||
+ if field.element in map_elements:
|
||||
+ return map_elements[field.element](field, display)
|
||||
+ return None
|
||||
+
|
||||
+ def show(self):
|
||||
+ self.display.print_info(self.label, self.value)
|
||||
+
|
||||
+
|
||||
+class ValueInfo(InformationElement):
|
||||
+ def __init__(self, field, display):
|
||||
+ super(ValueInfo, self).__init__(field, display)
|
||||
+ self.value = field.value or ''
|
||||
+ self.label = field.label
|
||||
+
|
||||
+class CheckInfo(InformationElement):
|
||||
+ def __init__(self, field, display):
|
||||
+ super(CheckInfo, self).__init__(field, display)
|
||||
+ self.label = field.label
|
||||
+ map_answer = {'on':_('yes'), 'off': _("no"), 'auto': _('auto')}
|
||||
+ self.value = map_answer.get(field.value, field.value)
|
||||
+
|
||||
+class ChoiceInfo(InformationElement):
|
||||
+ def __init__(self, field, display):
|
||||
+ super(ChoiceInfo, self).__init__(field, display)
|
||||
+ self.label = field.label or ''
|
||||
+ if field.choice and field.comments:
|
||||
+ map_comment = dict(zip(field.choice, field.comments))
|
||||
+ self.value = map_comment.get(field.value, field.value) or ''
|
||||
+ else:
|
||||
+ self.value = field.value if field.value else ''
|
||||
+
|
||||
+
|
||||
+class MultiChoiceInfo(InformationElement):
|
||||
+ def __init__(self, field, display):
|
||||
+ super(MultiChoiceInfo, self).__init__(field, display)
|
||||
+ self.label = field.label or ''
|
||||
+ if field.listvalue:
|
||||
+ value = field.listvalue
|
||||
+ # удалить пустой первый элемент (особенности wsdl)
|
||||
+ if value and not value[0]:
|
||||
+ value.pop(0)
|
||||
+ if field.choice and field.comments:
|
||||
+ map_comment = dict(zip(field.choice, field.comments))
|
||||
else:
|
||||
- value = []
|
||||
- value = ', '.join(value)
|
||||
- if field.listvalue and not value:
|
||||
- value = ', '.join(field.listvalue)
|
||||
- elif not value:
|
||||
- value = field.value if field.value else ''
|
||||
- if not print_group_flag:
|
||||
- if group_name:
|
||||
- print_group_flag = True
|
||||
- #_print('\b' + group_name)
|
||||
- _colorprint.bold.foreground(
|
||||
- TextState.Colors.WHITE)(group_name)
|
||||
- colorPrint.printSUCCESS('%s: %s' % (field.label, value))
|
||||
-
|
||||
- # elif field.element == 'label':
|
||||
- # print field.label
|
||||
-
|
||||
- elif field.element == 'error':
|
||||
- if not print_group_flag:
|
||||
- if group_name:
|
||||
- print_group_flag = True
|
||||
- _colorprint.bold.foreground(
|
||||
- TextState.Colors.WHITE)(group_name)
|
||||
- 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')
|
||||
+ map_comment = {}
|
||||
+ self.value = ", ".join([map_comment.get(x, x) or '' for x in value])
|
||||
+ else:
|
||||
+ self.value = field.value or ""
|
||||
+
|
||||
+
|
||||
+class ErrorInfo(InformationElement):
|
||||
+ def __init__(self, field, display):
|
||||
+ super(ErrorInfo, self).__init__(field, display)
|
||||
+ self.label = field.label
|
||||
+
|
||||
+ def show(self):
|
||||
+ self.display.print_error(self.label)
|
||||
+
|
||||
+
|
||||
+class TableInfo(InformationElement):
|
||||
+ """
|
||||
+ Табличная информация
|
||||
+ """
|
||||
+
|
||||
+ def map_row(self, row, typedata):
|
||||
+ map_answer = {'on':_('yes'), 'off': _("no"), 'auto': _('auto')}
|
||||
+ for cell, typefield in izip(row, typedata):
|
||||
+ if typefield in ['check', 'check_tristate']:
|
||||
+ yield map_answer.get(cell, cell) or ""
|
||||
+ elif "password" in typefield:
|
||||
+ yield "***"
|
||||
else:
|
||||
- value = field.value
|
||||
- if not print_group_flag:
|
||||
- if group_name:
|
||||
- print_group_flag = True
|
||||
- _colorprint.bold.foreground(
|
||||
- TextState.Colors.WHITE)(group_name)
|
||||
- colorPrint.printSUCCESS('%s: %s' % (field.label, value))
|
||||
-
|
||||
- elif field.element == 'table' and field.type != 'steps':
|
||||
- head = field.tablevalue.head
|
||||
-
|
||||
- body = []
|
||||
- for row in field.tablevalue.body:
|
||||
- if not row[0]:
|
||||
- row.pop(0)
|
||||
- body.append(row)
|
||||
-
|
||||
- # 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 + "\n")
|
||||
- continue
|
||||
- ChoiceValue = field.tablevalue.values
|
||||
- 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 "password" in ChoiceValue[row].typefield:
|
||||
- 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:
|
||||
- if group_name:
|
||||
- print_group_flag = True
|
||||
- _colorprint.bold.foreground(
|
||||
- TextState.Colors.WHITE)(group_name)
|
||||
- colorPrint.printSUCCESS(field.label + ': ')
|
||||
- res = printTable(data, head)
|
||||
- sys.stdout.flush()
|
||||
- sys.stdout.write(res + "\n")
|
||||
+ yield cell or ""
|
||||
+
|
||||
+ def __init__(self, field, display):
|
||||
+ super(TableInfo, self).__init__(field, display)
|
||||
+ self.label = field.label
|
||||
+ self.head = field.tablevalue.head
|
||||
+
|
||||
+ # удаление первого элемента строки (для wsdl)
|
||||
+ body = [x[1:] if x and not x[0] else x for x in field.tablevalue.body]
|
||||
+
|
||||
+ if not filter(None, map(lambda x: x, body)):
|
||||
+ self.body = None
|
||||
else:
|
||||
- uncompatible_count += 1
|
||||
+ type_values = [x.typefield for x in field.tablevalue.values]
|
||||
+ self.body = [list(self.map_row(x, type_values)) for x in body]
|
||||
+
|
||||
+ def show(self):
|
||||
+ if self.body:
|
||||
+ self.display.print_label(self.label)
|
||||
+ self.display.print_table(self.body, self.head)
|
||||
|
||||
|
||||
-# if uncompatible_count == len (Fields) and group_name:
|
||||
-# colorPrint.printSUCCESS(_('Not used'))
|
||||
+def print_brief_group(Fields, group_name):
|
||||
+ display = Display()
|
||||
+ show_group = True
|
||||
+ for element in ifilter(None,
|
||||
+ (InformationElement.from_field(
|
||||
+ FieldAdapter.from_detect(x),
|
||||
+ display)
|
||||
+ for x in Fields if not x.uncompatible)):
|
||||
+ if show_group:
|
||||
+ display.print_group(group_name)
|
||||
+ show_group = False
|
||||
+ element.show()
|
||||
+
|
||||
|
||||
class Table(tableReport):
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -953,4 +971,3 @@ def printTable(data, header=None):
|
||||
except Exception as e:
|
||||
print str(e)
|
||||
raise
|
||||
-
|
@ -0,0 +1,12 @@
|
||||
diff --git install/variables/distr.py install/variables/distr.py
|
||||
index 5c23c17..001b5cd 100644
|
||||
--- install/variables/distr.py
|
||||
+++ install/variables/distr.py
|
||||
@@ -143,6 +143,7 @@ class DistroRepository(Linux):
|
||||
|
||||
def listdistr(pathname):
|
||||
if path.exists(path.join(pathname,'etc/make.profile')) or \
|
||||
+ path.exists(path.join(pathname,'etc/portage/make.profile')) or \
|
||||
path.exists(path.join(pathname,'livecd')) or \
|
||||
pathname.startswith('/dev/'):
|
||||
return [pathname]
|
@ -0,0 +1,36 @@
|
||||
# Copyright 1999-2012 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: $
|
||||
|
||||
EAPI="3"
|
||||
SUPPORT_PYTHON_ABIS="1"
|
||||
PYTHON_DEPEND="2:2.7"
|
||||
RESTRICT_PYTHON_ABIS="2.4 2.5 2.6 3.*"
|
||||
|
||||
inherit distutils eutils
|
||||
|
||||
SRC_URI="ftp://ftp.calculate.ru/pub/calculate/calculate3/${PN}/${P}.tar.bz2"
|
||||
|
||||
DESCRIPTION="The library for Calculate 3"
|
||||
HOMEPAGE="http://www.calculate-linux.org/main/en/calculate2"
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="3"
|
||||
KEYWORDS="amd64 x86"
|
||||
IUSE="minimal"
|
||||
DEPEND="!minimal? ( dev-python/py-smbpasswd )
|
||||
>=dev-python/pyxml-0.8
|
||||
sys-apps/iproute2
|
||||
sys-apps/pciutils
|
||||
sys-fs/lvm2
|
||||
sys-fs/mdadm
|
||||
dev-python/pyinotify
|
||||
sys-apps/file[python]"
|
||||
RDEPEND="${DEPEND}"
|
||||
|
||||
src_unpack() {
|
||||
unpack "${A}"
|
||||
cd "${S}"
|
||||
|
||||
# apply revision changes
|
||||
epatch "${FILESDIR}/calculate-lib-3.2.0_alpha4-r1.patch"
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
diff --git calculate/lib/datavars.py calculate/lib/datavars.py
|
||||
index 1881294..3690083 100644
|
||||
--- calculate/lib/datavars.py
|
||||
+++ calculate/lib/datavars.py
|
||||
@@ -1017,9 +1017,10 @@ class DataVars(SimpleDataVars):
|
||||
"""
|
||||
if not self.iniCache:
|
||||
# get initialized section names
|
||||
- if os.path.exists('/etc/make.profile'):
|
||||
+ make_profile = self.Get('main.cl_make_profile')
|
||||
+ if os.path.exists(make_profile):
|
||||
profiles = [('profile',
|
||||
- path.join('/etc',os.readlink('/etc/make.profile')))]
|
||||
+ path.join('/etc',os.readlink(make_profile)))]
|
||||
else:
|
||||
profiles = []
|
||||
for iniName,iniFile in profiles+\
|
||||
diff --git calculate/lib/variables/env.py calculate/lib/variables/env.py
|
||||
index ab295ca..87d43cc 100644
|
||||
--- calculate/lib/variables/env.py
|
||||
+++ calculate/lib/variables/env.py
|
||||
@@ -414,6 +414,17 @@ class VariableClMakeProfile(Variable):
|
||||
"""
|
||||
Путь до актуального make.profile
|
||||
"""
|
||||
+ systemRoot = "/"
|
||||
+
|
||||
+ def get_work_link(self, *links):
|
||||
+ for link in links:
|
||||
+ if path.exists(link):
|
||||
+ return link
|
||||
+
|
||||
def get(self):
|
||||
- # TODO: заглушка, нужно учитывать /etc/portage/make.profile
|
||||
- return "/etc/make.profile"
|
||||
+ files = ["etc/portage/make.profile", "etc/make.profile"]
|
||||
+ val = self.get_work_link(
|
||||
+ *[path.join(self.systemRoot, x) for x in files])
|
||||
+ if not val:
|
||||
+ raise VariableError(_("Failed to detect system profile"))
|
||||
+ return val
|
||||
diff --git calculate/lib/variables/linux.py calculate/lib/variables/linux.py
|
||||
index 5d907f6..d49c773 100644
|
||||
--- calculate/lib/variables/linux.py
|
||||
+++ calculate/lib/variables/linux.py
|
||||
@@ -18,10 +18,10 @@ import os
|
||||
from os import path
|
||||
import re
|
||||
import platform
|
||||
-from calculate.lib.datavars import Variable,ReadonlyVariable,SimpleDataVars
|
||||
+from calculate.lib.datavars import Variable, SimpleDataVars
|
||||
from calculate.lib.utils.portage import isPkgInstalled
|
||||
-from calculate.lib.utils.files import countFiles,readFile
|
||||
-import calculate.lib.cl_template as cl_template
|
||||
+from calculate.lib.utils.files import readFile
|
||||
+from env import VariableClMakeProfile
|
||||
|
||||
class Linux:
|
||||
dictLinuxName = {"CLD":"Calculate Linux Desktop",
|
||||
@@ -51,7 +51,7 @@ class Linux:
|
||||
|
||||
def getShortnameByMakeprofile(self,systemroot):
|
||||
"""Get shortname by symlink of make.profile"""
|
||||
- makeprofile = path.join(systemroot,'etc/make.profile')
|
||||
+ makeprofile = self.Get('cl_make_profile')
|
||||
if path.exists(makeprofile):
|
||||
link = os.readlink(makeprofile)
|
||||
reMakeProfileLink = re.compile('/calculate/(desktop|server)/(%s)/'%
|
||||
@@ -78,11 +78,11 @@ class Linux:
|
||||
|
||||
def detectOtherShortname(self,systemroot):
|
||||
"""Detect other system. Now only Gentoo."""
|
||||
- gentooFile = path.join(systemroot,"etc/gentoo-release")
|
||||
+ gentooFile = path.join(systemroot, "etc/gentoo-release")
|
||||
if path.exists(gentooFile):
|
||||
return "Gentoo"
|
||||
- if all(map(lambda x:path.lexists(path.join(systemroot,x)),
|
||||
- ['bin','var','lib','etc'])):
|
||||
+ if all(map(lambda x: path.lexists(path.join(systemroot, x)),
|
||||
+ ['bin', 'var', 'lib', 'etc'])):
|
||||
return "Linux"
|
||||
return None
|
||||
|
||||
@@ -92,17 +92,17 @@ class Linux:
|
||||
"""
|
||||
overlayPath = 'var/lib/layman/calculate'
|
||||
releaseFile = 'profiles/calculate-release'
|
||||
- return readFile(path.join(systemroot,overlayPath,releaseFile))
|
||||
+ return readFile(path.join(systemroot, overlayPath, releaseFile))
|
||||
|
||||
def getVersionFromMetapackage(self,systemroot,shortname):
|
||||
"""Get version from meta package"""
|
||||
- for pkg in ("app-misc/calculate-meta","app-misc/%s-meta"%shortname):
|
||||
- calcMeta = isPkgInstalled(pkg,systemroot)
|
||||
+ for pkg in ("app-misc/calculate-meta", "app-misc/%s-meta" % shortname):
|
||||
+ calcMeta = isPkgInstalled(pkg, systemroot)
|
||||
if calcMeta:
|
||||
return calcMeta[0]['PV']
|
||||
return None
|
||||
|
||||
- def getVersionFromCalculateIni(self,systemroot):
|
||||
+ def getVersionFromCalculateIni(self, systemroot):
|
||||
"""Get version from calculate ini"""
|
||||
pathname = path.join(systemroot,
|
||||
'etc/calculate/calculate.ini')
|
||||
@@ -124,11 +124,9 @@ class Linux:
|
||||
def getVersionFromGentooFiles(self,systemroot):
|
||||
"""Get version from gentoo files"""
|
||||
gentooFile = path.join(systemroot,"etc/gentoo-release")
|
||||
- systemVersion = ""
|
||||
- flagGentoo = False
|
||||
reVer=re.compile("^(\d+\.)*\d+$",re.S)
|
||||
if path.exists(gentooFile):
|
||||
- gentooLink = path.join(systemroot,"etc/make.profile")
|
||||
+ gentooLink = self.Get('cl_make_profile')
|
||||
if path.islink(gentooLink):
|
||||
vers = filter(reVer.search,
|
||||
os.readlink(gentooLink).split('/'))
|
||||
@@ -227,9 +225,10 @@ class VariableOsLinuxFiles(Variable,Linux):
|
||||
|
||||
|
||||
class LinuxDataVars(SimpleDataVars):
|
||||
- def __init__(self,systemRoot="/"):
|
||||
+ def __init__(self, systemRoot="/"):
|
||||
self.systemRoot = systemRoot
|
||||
SimpleDataVars.__init__(self,
|
||||
+ VariableClMakeProfile(systemRoot=systemRoot),
|
||||
VariableOsLinuxShortname(systemRoot=systemRoot),
|
||||
VariableOsLinuxName(systemRoot=systemRoot),
|
||||
VariableOsLinuxSubname(systemRoot=systemRoot),
|
||||
@@ -238,14 +237,12 @@ class LinuxDataVars(SimpleDataVars):
|
||||
VariableOsLinuxSystem(systemRoot=systemRoot),
|
||||
VariableOsLinuxVer(systemRoot=systemRoot),
|
||||
VariableOsLinuxBuild(systemRoot=systemRoot))
|
||||
- makeprofile = path.join(systemRoot,'etc/make.profile')
|
||||
+ makeprofile = self.Get('cl_make_profile')
|
||||
if os.path.exists(makeprofile):
|
||||
- inifile = path.join(systemRoot,'etc',
|
||||
- os.readlink(path.join(systemRoot,'etc/make.profile')))
|
||||
+ inifile = path.join(systemRoot, 'etc',
|
||||
+ os.readlink(makeprofile))
|
||||
self.flIniFileFrom(inifile)
|
||||
- inifile = "etc/calculate/calculate.env"
|
||||
- self.flIniFileFrom(path.join(systemRoot,inifile))
|
||||
- iniFile = "etc/calculate/calculate3.env"
|
||||
- self.flIniFileFrom(path.join(systemRoot,iniFile))
|
||||
- iniFile = "etc/calculate/calculate2.env"
|
||||
- self.flIniFileFrom(path.join(systemRoot,iniFile))
|
||||
+ for inifile in ("etc/calculate/calculate.env",
|
||||
+ "etc/calculate/calculate3.env",
|
||||
+ "etc/calculate/calculate2.env"):
|
||||
+ self.flIniFileFrom(path.join(systemRoot, inifile))
|
@ -0,0 +1,33 @@
|
||||
# Copyright 1999-2012 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: $
|
||||
|
||||
EAPI="3"
|
||||
SUPPORT_PYTHON_ABIS="1"
|
||||
PYTHON_DEPEND="2:2.7"
|
||||
RESTRICT_PYTHON_ABIS="2.4 2.5 2.6 3.*"
|
||||
|
||||
inherit distutils eutils
|
||||
|
||||
SRC_URI="ftp://ftp.calculate.ru/pub/calculate/calculate3/${PN}/${P}.tar.bz2"
|
||||
|
||||
DESCRIPTION="The program of update Calculate Linux"
|
||||
HOMEPAGE="http://www.calculate-linux.org/main/en/calculate2"
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="3"
|
||||
KEYWORDS="amd64 x86"
|
||||
IUSE=""
|
||||
|
||||
DEPEND="~sys-apps/calculate-core-3.2.0_alpha4
|
||||
~sys-apps/calculate-install-3.2.0_alpha4
|
||||
dev-python/pexpect"
|
||||
|
||||
RDEPEND="${DEPEND}"
|
||||
|
||||
src_unpack() {
|
||||
unpack "${A}"
|
||||
cd "${S}"
|
||||
|
||||
# apply revision changes
|
||||
epatch "${FILESDIR}/calculate-update-3.2.0_alpha4-r1.patch"
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
diff --git update/emerge_parser.py update/emerge_parser.py
|
||||
index 50d53aa..3095b7e 100644
|
||||
--- update/emerge_parser.py
|
||||
+++ update/emerge_parser.py
|
||||
@@ -13,6 +13,7 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
+import hashlib
|
||||
|
||||
import os
|
||||
from os import path
|
||||
@@ -531,6 +532,10 @@ class MtimeCheckvalue(object):
|
||||
return self.get_check_values(self.fname)
|
||||
|
||||
|
||||
+class Md5Checkvalue(MtimeCheckvalue):
|
||||
+ def value_func(self, fn):
|
||||
+ return hashlib.md5(readFile(fn)).hexdigest()
|
||||
+
|
||||
class GitCheckvalue(object):
|
||||
def __init__(self, rpath):
|
||||
self.rpath = rpath
|
||||
@@ -550,9 +555,9 @@ class EmergeCache(object):
|
||||
# список файлов проверяемый по mtime на изменения
|
||||
check_list = [MtimeCheckvalue('/etc/make.conf',
|
||||
'/etc/portage',
|
||||
- '/var/lib/portage/world',
|
||||
- '/var/lib/portage/world_sets',
|
||||
- '/etc/make.profile')]
|
||||
+ '/etc/make.profile'),
|
||||
+ Md5Checkvalue('/var/lib/portage/world',
|
||||
+ '/var/lib/portage/world_sets')]
|
||||
|
||||
def __init__(self):
|
||||
self.files_control_values = {}
|
||||
diff --git update/update.py update/update.py
|
||||
index 5d8936c..cb8b0b5 100644
|
||||
--- update/update.py
|
||||
+++ update/update.py
|
||||
@@ -467,7 +467,7 @@ class Update:
|
||||
emerge.uninstalling.add_observer(self._printUninstallPackage)
|
||||
try:
|
||||
emerge.run()
|
||||
- except EmergeError as e:
|
||||
+ except EmergeError:
|
||||
self.emerge_cache.drop_cache()
|
||||
if emerge.emerging_error:
|
||||
self.printPre(
|
||||
diff --git update/variables/update.py update/variables/update.py
|
||||
index 0f79468..a000e45 100644
|
||||
--- update/variables/update.py
|
||||
+++ update/variables/update.py
|
||||
@@ -117,8 +117,10 @@ class VariableClUpdateSystemProfile(ReadonlyVariable):
|
||||
"""
|
||||
def get(self):
|
||||
try:
|
||||
+ make_profile = self.Get('cl_make_profile')
|
||||
return path.normpath(
|
||||
- path.join('/etc',os.readlink('/etc/make.profile')))
|
||||
+ path.join(path.dirname(make_profile),
|
||||
+ os.readlink(make_profile)))
|
||||
except:
|
||||
raise VariableError(_("Failed to determine system profile"))
|
||||
|
@ -0,0 +1,26 @@
|
||||
# Copyright 1999-2011 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: $
|
||||
|
||||
EAPI=4
|
||||
|
||||
DESCRIPTION="Calculate Utilities meta package"
|
||||
HOMEPAGE="http://www.calculate-linux.org/main/en/calculate2"
|
||||
SRC_URI=""
|
||||
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="3"
|
||||
KEYWORDS="amd64 x86"
|
||||
IUSE="cl_consolegui cl_client cl_desktop cl_console"
|
||||
|
||||
RDEPEND="${RDEPEND}
|
||||
=sys-apps/calculate-install-3.2.0_alpha4
|
||||
=sys-apps/calculate-i18n-3.2.0_alpha4
|
||||
=sys-apps/calculate-lib-3.2.0_alpha4-r1
|
||||
=sys-apps/calculate-core-3.2.0_alpha4-r1
|
||||
=sys-apps/calculate-update-3.2.0_alpha4-r1
|
||||
cl_client? ( =sys-apps/calculate-client-3.2.0_alpha4 )
|
||||
cl_desktop? ( =sys-apps/calculate-desktop-3.2.0_alpha4 )
|
||||
cl_consolegui? ( =sys-apps/calculate-console-gui-3.2.0_alpha4 )
|
||||
cl_console? ( =sys-apps/calculate-console-3.2.0_alpha4 )
|
||||
"
|
Loading…
Reference in new issue