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.
develop
Самоукин Алексей 14 years ago
parent 9e67c48b6d
commit a2de191f04

Binary file not shown.

@ -17,7 +17,7 @@
import os import os
import sys import sys
from cl_utils import convertStrListDict, fillstr, getpathenv, runOsCommand,\ from cl_utils import convertStrListDict, fillstr, getpathenv, runOsCommand,\
pathJoin pathJoin, _toUNICODE
from cl_vars_share import varsShare as glob_attr from cl_vars_share import varsShare as glob_attr
import re import re
from cl_lang import lang from cl_lang import lang
@ -600,7 +600,7 @@ storage of variables templates")%location)
break break
return foundVar return foundVar
def getVars(self, varsFilter=None, varsNames=[]): def getVars(self, varsFilter=None, varsNames=[], verbose=1):
"""Словарь переменных для печати""" """Словарь переменных для печати"""
# проверка фильтра # проверка фильтра
reFilter = False reFilter = False
@ -616,9 +616,9 @@ storage of variables templates")%location)
dataVar = moduleVar.Data dataVar = moduleVar.Data
dictVars = dir(dataVar) dictVars = dir(dataVar)
for nameVar in dictVars: 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).has_key("hide") and\
getattr(dataVar,nameVar)['hide']): getattr(dataVar,nameVar)['hide']) or verbose>1):
if varsNames and not nameVar in varsNames: if varsNames and not nameVar in varsNames:
continue continue
if reFilter and not reFilter.search(nameVar): if reFilter and not reFilter.search(nameVar):
@ -627,10 +627,10 @@ storage of variables templates")%location)
ret[nameVar] = getattr(self, nameVar) ret[nameVar] = getattr(self, nameVar)
return ret 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, verbose=verbose)
var=self.getVars(varsFilter, varsNames)
if outFormat == "default": if outFormat == "default":
mlen_name=0; mlen_name=0;
mlen_type=0; mlen_type=0;
@ -648,7 +648,8 @@ storage of variables templates")%location)
br = fillstr("-",mlen_name) + " " +\ br = fillstr("-",mlen_name) + " " +\
fillstr("-",mlen_mode) + " " + fillstr("-",10) fillstr("-",mlen_mode) + " " + fillstr("-",10)
cl_overriding.printSUCCESS(_("The list of variables:")) 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")) " " + _("Mode") + " " +_("Value"))
cl_overriding.printSUCCESS(br) cl_overriding.printSUCCESS(br)
for i in plist: for i in plist:

@ -50,6 +50,16 @@ class fillVars(varsShare):
_("Template variable cl_env_data is empty")) _("Template variable cl_env_data is empty"))
cl_overriding.exit(1) 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): def get_cl_template_clt_path(self):
"""Path to 'clt' files""" """Path to 'clt' files"""
if "CONFIG_PROTECT" in os.environ: if "CONFIG_PROTECT" in os.environ:
@ -600,3 +610,23 @@ class fillVars(varsShare):
return "on" if isMount('/mnt/scratch/workspace') else "off" return "on" if isMount('/mnt/scratch/workspace') else "off"
else: else:
return "on" if isMount('/mnt/scratch') else "off" 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 {}

@ -26,7 +26,7 @@ tr.setLocalDomain('cl_lib')
tr.setLanguage(sys.modules[__name__]) tr.setLanguage(sys.modules[__name__])
optparse._ = _ optparse._ = _
def make_option(shortOption=None,longOption=None, def make_option(shortOption=None, longOption=None,
optVal=None, help=None, default=None, optVal=None, help=None, default=None,
action=None, type=None, choices=None): action=None, type=None, choices=None):
"""Make option. Used for processing options parameter in opt __init__. """Make option. Used for processing options parameter in opt __init__.
@ -269,7 +269,9 @@ class opt(optparse.OptionParser):
}, },
{'shortOption':"v", {'shortOption':"v",
'longOption':"vars", 'longOption':"vars",
'help':_("print variables") 'action':'count',
'help':_("print variables, if the two options is verbose "
"(added print hidden variables)")
}, },
{'longOption':"filter", {'longOption':"filter",
'optVal':"FILTER", 'optVal':"FILTER",

@ -23,22 +23,22 @@
class Data: class Data:
# computer hostname # computer hostname
os_net_hostname = {'mode':"w"} os_net_hostname = {'hide':True, 'mode':"w"}
# allowed networks # allowed networks
os_net_allow ={} os_net_allow ={'hide':True}
# ip for all network interfaces (comma delimeter) # ip for all network interfaces (comma delimeter)
os_net_ip ={} os_net_ip ={'hide':True}
# network interfaces # network interfaces
os_net_interfaces={'hide':True} os_net_interfaces={'hide':True}
# computer domain # computer domain
os_net_domain = {'mode':"w"} os_net_domain = {'hide':True, 'mode':"w"}
# short system name (CLD) # short system name (CLD)
os_linux_shortname={} os_linux_shortname={'hide':True}
# aliases and path to ini files # aliases and path to ini files
cl_env_data = {'hide':True, cl_env_data = {'hide':True,
@ -50,72 +50,73 @@ class Data:
cl_env_location = {'hide':True} cl_env_location = {'hide':True}
# path to ini files (from cl_env_data) # path to ini files (from cl_env_data)
cl_env_path = {} cl_env_path = {'hide':True}
# path to information file on server # path to information file on server
cl_env_server_path = {'hide':True, cl_env_server_path = {'hide':True}
'value':'/var/calculate/remote/server.env'}
# paths to template files # paths to template files
cl_template_path = {'value':["/usr/share/calculate/templates", cl_template_path = {'hide':True}
"/var/calculate/templates",
"/var/calculate/remote/templates"]} # paths to clt-template files
# paths to clt-template files cl_template_clt_path = {'hide':True}
cl_template_clt_path = {}
# locale (at example: ru_RU.UTF-8) # locale (at example: ru_RU.UTF-8)
os_locale_locale = {} os_locale_locale = {'hide':True}
# full language (at example: ru_RU) # full language (at example: ru_RU)
os_locale_lang = {} os_locale_lang = {'hide':True}
# short language (at example ru) # short language (at example ru)
os_locale_language = {} os_locale_language = {'hide':True}
# keyboard layout for X server # keyboard layout for X server
os_locale_xkb = {} os_locale_xkb = {'hide':True}
# keyboard layout name for X server # keyboard layout name for X server
os_locale_xkbname = {} os_locale_xkbname = {'hide':True}
# computer architecture (i686,x86_64) # computer architecture (i686,x86_64)
os_arch_machine = {} os_arch_machine = {'hide':True}
# pass for templates join 1,2,3,4,5 and etc # pass for templates join 1,2,3,4,5 and etc
cl_pass_step = {} cl_pass_step = {'hide':True}
# template file performed at now # template file performed at now
cl_pass_file = {'mode':"w"} cl_pass_file = {'hide':True, 'mode':"w"}
# root partition of filesystem # root partition of filesystem
os_root_dev = {} os_root_dev = {'hide':True}
# root type (ram, hdd, usb-hdd, livecd) # root type (ram, hdd, usb-hdd, livecd)
os_root_type = {} os_root_type = {'hide':True}
# full system name # full system name
os_linux_name = {} os_linux_name = {'hide':True}
# postfix to system name (KDE GNOME and etc) # postfix to system name (KDE GNOME and etc)
os_linux_subname = {} os_linux_subname = {'hide':True}
# system (desktop or server) # system (desktop or server)
os_linux_system = {} os_linux_system = {'hide':True}
# motherboard model # motherboard model
hr_board_model = {} hr_board_model = {'hide':True}
# motherboard vendor # motherboard vendor
hr_board_vendor = {} hr_board_vendor = {'hide':True}
# processors count # processors count
hr_cpu_num = {} hr_cpu_num = {'hide':True}
# virtual machine name (virtualbox, vmware, qemu) # virtual machine name (virtualbox, vmware, qemu)
hr_virtual = {} hr_virtual = {'hide':True}
# system version # system version
os_linux_ver = {} os_linux_ver = {'hide':True}
# user login # user login
ur_login = {} ur_login = {'hide':True}
# user group name # user group name
ur_group = {'hide':True} ur_group = {'hide':True}
@ -128,18 +129,18 @@ class Data:
# path to directory relative which perform joining templates to system files # path to directory relative which perform joining templates to system files
# (sandbox) # (sandbox)
cl_root_path = {'mode':"w", 'value':"/"} cl_root_path = {'hide':True, 'mode':"w"}
# path to directory which contain other system # path to directory which contain other system
cl_chroot_path = {'mode':"r", 'value':"/"} cl_chroot_path = {'hide':True}
# program action # program action
# install, uninstall, merge, domain, undomain, system, desktop # install, uninstall, merge, domain, undomain, system, desktop
cl_action = {} cl_action = {'hide':True}
# program state # program state
# specifies addition to cl_pass_action for needing # specifies addition to cl_pass_action for needing
cl_pass_state = {} cl_pass_state = {'hide':True}
# User Jabber ID # User Jabber ID
ur_jid = {'hide':True} ur_jid = {'hide':True}
@ -148,7 +149,7 @@ class Data:
ur_mail = {'hide':True} ur_mail = {'hide':True}
# kernel uid get by uuid root device # kernel uid get by uuid root device
cl_kernel_uid = {} cl_kernel_uid = {'hide':True}
# variable for calculate-client and calculate-desktop packages # variable for calculate-client and calculate-desktop packages
# ip or domain name of CDS # ip or domain name of CDS
cl_remote_host = {'mode':'r', 'hide':True} cl_remote_host = {'mode':'r', 'hide':True}
@ -161,34 +162,34 @@ class Data:
cl_belong_pkg = {'mode':'r', 'hide':True} cl_belong_pkg = {'mode':'r', 'hide':True}
# vertical resolution for X server # vertical resolution for X server
os_x11_height = {'mode':"w"} os_x11_height = {'mode':"w", 'hide':True}
# horizontal resolution for X server # 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 # 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 # if computer is noteboot, the this variable containt its vendor
hr_laptop = {} hr_laptop = {'hide':True}
# video verdor name # video verdor name
hr_video = {} hr_video = {'hide':True}
# Video driver used by xorg # Video driver used by xorg
os_x11_video_drv = {} os_x11_video_drv = {'hide':True}
# on/off composite mode # on/off composite mode
os_x11_composite = {} os_x11_composite = {'hide':True}
# current system is scratch # current system is scratch
os_scratch = {} os_scratch = {'hide':True}
# programs have templates setup # programs have templates setup
cl_merges = {} cl_merges = {'hide':True}
# (on or off) autoupdate config from install program # (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 # The path to the module api, and additional parameters caluclate packages
cl_api = {'mode':'r', 'hide':True, 'value':{}} cl_api = {'hide':True}

Loading…
Cancel
Save