From a2de191f0474d8a78bdfb33fdc1dfb974b3b04e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D0=BC=D0=BE=D1=83=D0=BA=D0=B8=D0=BD=20=D0=90?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 13 Oct 2010 11:02:06 +0400 Subject: [PATCH] Modified method of printing variables. We attribute variables official replaced hide. Modified algorithm to determine the section to write the variable with higher priority in the library variables. Variables with a certain value are replaced by variables with the method of filling. --- i18n/cl_lib_ru.mo | Bin 24306 -> 24494 bytes pym/cl_datavars.py | 17 ++++---- pym/cl_fill.py | 30 ++++++++++++++ pym/cl_opt.py | 6 ++- pym/cl_vars.py | 97 +++++++++++++++++++++++---------------------- 5 files changed, 92 insertions(+), 58 deletions(-) diff --git a/i18n/cl_lib_ru.mo b/i18n/cl_lib_ru.mo index bd2cc04cf186edd60c0b33c71f0f79157a68bed9..dfe20287df8eef32b2ff8403fcbe57798e617382 100644 GIT binary patch delta 2081 zcmYk+e@xVM7{Kx8($PxsN`91>@Rj1?@J@b(0ToJVhKN8RA!?2vhuow)#$8y6oLT-F zg)aKBH8b6`H5g7fNP!{KL971A@BLwIELTZp`G+fN)>^gRPv85a?e1Qm=lkRHeLm0U zx$o?_?ev80%<7m>nTWjV6nO|EI2U6wMEJ-&ejK<0Q*bL5;BLGF&*J@f0l8JK;Zn3O z6G_EvjK`{|UbGW;VghzAlaM4bILU!Lo5&cJ6aV58S%}4MD}gH12k$~nbQrVo2FBri z%dH1x;U?lWxE4RaGQ5slDtVbAmDqqAaX2$1vV+0AERkH?i4S8R>H}wxoMZ`4TZbj6 z$KOId{sl6Z{D}`>Mve%%OF3#KI&c*p!xH=kA44Y((}cE%7_4OQHWuM!%)@w=nTG37 zAJmFZ;!)HJ&0ss`a`AlZ#Rfc!PvGJeR$|*w?>~&mIEI?oG-{%uzZg&*akA{qSc5D^ zhAMqU6&GU|b>)|$#ukb^%JZev8puI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02HvK8 zi+P3~iAgQRz;`hNIK=F^^Q>ZFjh4+4Z)YxWfWvu-K5Rywe2m$Io0th6p~MRDn}I%xfeRzLat$|g9kZD(G8d|TxcH+nli8e0 z*^k@#EZ=69x@J+t6KvoZ?qMc$l9^y9<;lROadvjcN`qDxj!;!%&?A1C_#7wjILEPk uNim>l^a+h8nMZSwWprD#`TM$KXT`uyWzq3bk28HbPSjV9=vcO>xy%0wSoS;s diff --git a/pym/cl_datavars.py b/pym/cl_datavars.py index 65d613e..04331a3 100644 --- a/pym/cl_datavars.py +++ b/pym/cl_datavars.py @@ -17,7 +17,7 @@ import os import sys from cl_utils import convertStrListDict, fillstr, getpathenv, runOsCommand,\ - pathJoin + pathJoin, _toUNICODE from cl_vars_share import varsShare as glob_attr import re from cl_lang import lang @@ -600,7 +600,7 @@ storage of variables templates")%location) break return foundVar - def getVars(self, varsFilter=None, varsNames=[]): + def getVars(self, varsFilter=None, varsNames=[], verbose=1): """Словарь переменных для печати""" # проверка фильтра reFilter = False @@ -616,9 +616,9 @@ storage of variables templates")%location) dataVar = moduleVar.Data dictVars = dir(dataVar) for nameVar in dictVars: - if not "__" in nameVar and not\ + if not "__" in nameVar and (not\ (getattr(dataVar,nameVar).has_key("hide") and\ - getattr(dataVar,nameVar)['hide']): + getattr(dataVar,nameVar)['hide']) or verbose>1): if varsNames and not nameVar in varsNames: continue if reFilter and not reFilter.search(nameVar): @@ -627,10 +627,10 @@ storage of variables templates")%location) ret[nameVar] = getattr(self, nameVar) return ret - def printVars(self, varsFilter=None, varsNames=[], outFormat="default"): + def printVars(self, varsFilter=None, varsNames=[], outFormat="default", + verbose=1): """распечатать список переменных с значениями""" - var=None - var=self.getVars(varsFilter, varsNames) + var=self.getVars(varsFilter, varsNames, verbose=verbose) if outFormat == "default": mlen_name=0; mlen_type=0; @@ -648,7 +648,8 @@ storage of variables templates")%location) br = fillstr("-",mlen_name) + " " +\ fillstr("-",mlen_mode) + " " + fillstr("-",10) cl_overriding.printSUCCESS(_("The list of variables:")) - cl_overriding.printSUCCESS(_("Variable name").center(mlen_name) +\ + cl_overriding.printSUCCESS(\ + _toUNICODE(_("Variable name")).center(mlen_name).encode('UTF-8') +\ " " + _("Mode") + " " +_("Value")) cl_overriding.printSUCCESS(br) for i in plist: diff --git a/pym/cl_fill.py b/pym/cl_fill.py index 62f7cf8..8639ae1 100644 --- a/pym/cl_fill.py +++ b/pym/cl_fill.py @@ -50,6 +50,16 @@ class fillVars(varsShare): _("Template variable cl_env_data is empty")) cl_overriding.exit(1) + def get_cl_env_server_path(self): + """Paths to clt-template files""" + return '/var/calculate/remote/server.env' + + def get_cl_template_path(self): + """Paths to template files""" + return ["/usr/share/calculate/templates", + "/var/calculate/templates", + "/var/calculate/remote/templates"] + def get_cl_template_clt_path(self): """Path to 'clt' files""" if "CONFIG_PROTECT" in os.environ: @@ -600,3 +610,23 @@ class fillVars(varsShare): return "on" if isMount('/mnt/scratch/workspace') else "off" else: return "on" if isMount('/mnt/scratch') else "off" + + def get_cl_root_path(self): + """Path to directory relative which perform joining templates to + + system files (sandbox)""" + return '/' + + def get_cl_chroot_path(self): + """Path to directory which contain other system""" + return '/' + + def get_cl_autoupdate_set(self): + """(on or off) autoupdate config from install program""" + return 'off' + + def get_cl_api(self): + """The path to the module api, + + and additional parameters caluclate packages""" + return {} diff --git a/pym/cl_opt.py b/pym/cl_opt.py index 61ef616..1d4a789 100644 --- a/pym/cl_opt.py +++ b/pym/cl_opt.py @@ -26,7 +26,7 @@ tr.setLocalDomain('cl_lib') tr.setLanguage(sys.modules[__name__]) optparse._ = _ -def make_option(shortOption=None,longOption=None, +def make_option(shortOption=None, longOption=None, optVal=None, help=None, default=None, action=None, type=None, choices=None): """Make option. Used for processing options parameter in opt __init__. @@ -269,7 +269,9 @@ class opt(optparse.OptionParser): }, {'shortOption':"v", 'longOption':"vars", - 'help':_("print variables") + 'action':'count', + 'help':_("print variables, if the two options is verbose " + "(added print hidden variables)") }, {'longOption':"filter", 'optVal':"FILTER", diff --git a/pym/cl_vars.py b/pym/cl_vars.py index 9abf461..20b50a8 100644 --- a/pym/cl_vars.py +++ b/pym/cl_vars.py @@ -23,22 +23,22 @@ class Data: # computer hostname - os_net_hostname = {'mode':"w"} + os_net_hostname = {'hide':True, 'mode':"w"} # allowed networks - os_net_allow ={} + os_net_allow ={'hide':True} # ip for all network interfaces (comma delimeter) - os_net_ip ={} + os_net_ip ={'hide':True} # network interfaces os_net_interfaces={'hide':True} # computer domain - os_net_domain = {'mode':"w"} + os_net_domain = {'hide':True, 'mode':"w"} # short system name (CLD) - os_linux_shortname={} + os_linux_shortname={'hide':True} # aliases and path to ini files cl_env_data = {'hide':True, @@ -50,72 +50,73 @@ class Data: cl_env_location = {'hide':True} # path to ini files (from cl_env_data) - cl_env_path = {} + cl_env_path = {'hide':True} # path to information file on server - cl_env_server_path = {'hide':True, - 'value':'/var/calculate/remote/server.env'} + cl_env_server_path = {'hide':True} # paths to template files - cl_template_path = {'value':["/usr/share/calculate/templates", - "/var/calculate/templates", - "/var/calculate/remote/templates"]} - # paths to clt-template files - cl_template_clt_path = {} + cl_template_path = {'hide':True} + + # paths to clt-template files + cl_template_clt_path = {'hide':True} + # locale (at example: ru_RU.UTF-8) - os_locale_locale = {} + os_locale_locale = {'hide':True} + # full language (at example: ru_RU) - os_locale_lang = {} + os_locale_lang = {'hide':True} + # short language (at example ru) - os_locale_language = {} + os_locale_language = {'hide':True} # keyboard layout for X server - os_locale_xkb = {} + os_locale_xkb = {'hide':True} # keyboard layout name for X server - os_locale_xkbname = {} + os_locale_xkbname = {'hide':True} # computer architecture (i686,x86_64) - os_arch_machine = {} + os_arch_machine = {'hide':True} # pass for templates join 1,2,3,4,5 and etc - cl_pass_step = {} + cl_pass_step = {'hide':True} # template file performed at now - cl_pass_file = {'mode':"w"} + cl_pass_file = {'hide':True, 'mode':"w"} # root partition of filesystem - os_root_dev = {} + os_root_dev = {'hide':True} # root type (ram, hdd, usb-hdd, livecd) - os_root_type = {} + os_root_type = {'hide':True} # full system name - os_linux_name = {} + os_linux_name = {'hide':True} # postfix to system name (KDE GNOME and etc) - os_linux_subname = {} + os_linux_subname = {'hide':True} # system (desktop or server) - os_linux_system = {} + os_linux_system = {'hide':True} # motherboard model - hr_board_model = {} + hr_board_model = {'hide':True} # motherboard vendor - hr_board_vendor = {} + hr_board_vendor = {'hide':True} # processors count - hr_cpu_num = {} + hr_cpu_num = {'hide':True} # virtual machine name (virtualbox, vmware, qemu) - hr_virtual = {} + hr_virtual = {'hide':True} # system version - os_linux_ver = {} + os_linux_ver = {'hide':True} # user login - ur_login = {} + ur_login = {'hide':True} # user group name ur_group = {'hide':True} @@ -128,18 +129,18 @@ class Data: # path to directory relative which perform joining templates to system files # (sandbox) - cl_root_path = {'mode':"w", 'value':"/"} + cl_root_path = {'hide':True, 'mode':"w"} # path to directory which contain other system - cl_chroot_path = {'mode':"r", 'value':"/"} + cl_chroot_path = {'hide':True} # program action # install, uninstall, merge, domain, undomain, system, desktop - cl_action = {} + cl_action = {'hide':True} # program state # specifies addition to cl_pass_action for needing - cl_pass_state = {} + cl_pass_state = {'hide':True} # User Jabber ID ur_jid = {'hide':True} @@ -148,7 +149,7 @@ class Data: ur_mail = {'hide':True} # kernel uid get by uuid root device - cl_kernel_uid = {} + cl_kernel_uid = {'hide':True} # variable for calculate-client and calculate-desktop packages # ip or domain name of CDS cl_remote_host = {'mode':'r', 'hide':True} @@ -161,34 +162,34 @@ class Data: cl_belong_pkg = {'mode':'r', 'hide':True} # vertical resolution for X server - os_x11_height = {'mode':"w"} + os_x11_height = {'mode':"w", 'hide':True} # horizontal resolution for X server - os_x11_width = {'mode':"w"} + os_x11_width = {'mode':"w", 'hide':True} # the nearest standard size of image to current screen resolution - os_x11_standart = {} + os_x11_standart = {'hide':True} # if computer is noteboot, the this variable containt its vendor - hr_laptop = {} + hr_laptop = {'hide':True} # video verdor name - hr_video = {} + hr_video = {'hide':True} # Video driver used by xorg - os_x11_video_drv = {} + os_x11_video_drv = {'hide':True} # on/off composite mode - os_x11_composite = {} + os_x11_composite = {'hide':True} # current system is scratch - os_scratch = {} + os_scratch = {'hide':True} # programs have templates setup - cl_merges = {} + cl_merges = {'hide':True} # (on or off) autoupdate config from install program - cl_autoupdate_set = {'hide':True, 'value': "off"} + cl_autoupdate_set = {'hide':True} # The path to the module api, and additional parameters caluclate packages - cl_api = {'mode':'r', 'hide':True, 'value':{}} + cl_api = {'hide':True}