Browse Source

Sync english messages with i18n.

develop
Mike Hiretsky 10 years ago
parent
commit
5044f529a6
  1. 12
      pym/cl_api.py
  2. 19
      pym/cl_datavars.py
  3. 7
      pym/cl_fill.py
  4. 2
      pym/cl_ldap.py
  5. 17
      pym/cl_opt.py
  6. 3
      pym/cl_string.py
  7. 311
      pym/cl_template.py
  8. 9
      pym/cl_utils.py
  9. 3
      pym/client/progressbar.py
  10. 18
      pym/encrypt.py
  11. 14
      pym/format/patch.py
  12. 8
      pym/format/xml_gconf.py
  13. 2
      pym/format/xml_gconf_tree.py
  14. 2
      pym/format/xml_xfce.py
  15. 2
      pym/format/xml_xfcepanel.py
  16. 14
      pym/server/ldap.py
  17. 4
      pym/server/share.py
  18. 30
      pym/server/users.py
  19. 20
      pym/update_config/cl_update_config.py
  20. 2
      pym/update_config/cl_update_config_cmd.py
  21. 8
      pym/utils/ip.py

12
pym/cl_api.py

@ -61,7 +61,7 @@ class _services(color_print, libVars):
'serviceAPI')
except (ImportError, AttributeError), e:
self.printERROR(str(e).strip())
self.printERROR(_("Can not import module %s")% apiFile)
self.printERROR(_("Failed to import module %s")% apiFile)
cl_overriding.exit(1)
return className
@ -80,7 +80,7 @@ class _services(color_print, libVars):
apiObject = className()
except Exception, e:
self.printERROR(str(e).strip())
self.printERROR(_("Can not create API object"))
self.printERROR(_("Failed create an API object"))
self.printERROR(_("Module %s")% apiFile)
cl_overriding.exit(1)
self.apiObjs[pkgName] = apiObject
@ -101,7 +101,7 @@ class _services(color_print, libVars):
try:
apiObjects.append(className())
except:
self.printERROR(_("Can not create API object"))
self.printERROR(_("Failed create an API object"))
self.printERROR(_("Module %s")% apiFile)
cl_overriding.exit(1)
return apiObjects
@ -113,8 +113,8 @@ class _services(color_print, libVars):
return ""
if not hasattr(pkgObj, methodName) or\
not callable(getattr(pkgObj, methodName)):
self.printERROR(_("Can not found method %(method)s in \
API object service %(service)s") %{'method':methodName,
self.printERROR(_("Method %(method)s not found in object API of"
" service %(service)s") %{'method':methodName,
'service':pkgObj.getServiceName()})
cl_overriding.exit(1)
if argv:
@ -201,7 +201,7 @@ class _pkgAPI(object):
try:
value = object.__getattribute__(self, attr)()
except:
raise APIError(_("Can not found method %s")%attr)
raise APIError(_("Method %s not found")%attr)
return value
class _allPkg(object):

19
pym/cl_datavars.py

@ -144,7 +144,7 @@ class DataVars(object):
try:
globals()[modVar] = __import__(modVar)
except (ImportError, AttributeError), e:
err1 = _("Error in import module %s")%modVar
err1 = _("Error in importing module %s")%modVar
err2 = _("error") + ": " +str(e)
raise self.DataVarsError("%s\n%s"%(err1,err2))
@ -155,7 +155,7 @@ class DataVars(object):
if "No module named" in str(e):
flagFindFillModule = False
else:
err1 = _("Error in import module %s")%modFill
err1 = _("Error in importing module %s")%modFill
err2 = _("error") + ": " +str(e)
raise self.DataVarsError("%s\n%s"%(err1,err2))
@ -189,7 +189,7 @@ class DataVars(object):
if dataVar is False:
dataVar = dataVarWork
if dataVar == False:
err1 = _("Not found variable %s")%nameVar
err1 = _("Variable %s not found")%nameVar
err2 = ""
if e:
err2 = _("error") + ": " +str(e)
@ -215,7 +215,7 @@ class DataVars(object):
"""
if not set(dictVar.keys()) <= set(dir(var)):
raise self.DataVarsError(\
_("error initalize variable %s, incorrect data")%nameVar)
_("error in initalizing variable %s, incorrect data")%nameVar)
for nameAttr in dictVar.keys():
setattr(var, nameAttr, dictVar[nameAttr])
return True
@ -340,8 +340,8 @@ class DataVars(object):
name_calculate_ini = ini_dict[location]
else:
cl_overriding.printERROR(\
_("Unable to find the alias '%s' of the file path for \
storage of variables templates")%location)
_("Unable to find alias '%s' of the path to the file "
"storing template variables templates")%location)
cl_overriding.exit(1)
return pathJoin(self.Get('cl_chroot_path'), name_calculate_ini)
@ -354,7 +354,7 @@ storage of variables templates")%location)
try:
self.Get(vname)
except self.DataVarsError, e:
cl_overriding.printERROR(_("Not found template variable %s")\
cl_overriding.printERROR(_("Template variable %s not found")\
%vname)
cl_overriding.printERROR(e)
cl_overriding.exit(1)
@ -581,7 +581,8 @@ storage of variables templates")%location)
try:
value = self.Get(vname)
except:
cl_overriding.printERROR(_("error var %s not found")%str(vname))
cl_overriding.printERROR(_("error, variable %s not found")%
str(vname))
cl_overriding.exit(1)
if value:
return True
@ -612,7 +613,7 @@ storage of variables templates")%location)
try:
reFilter = re.compile("%s"%varsFilter)
except:
cl_overriding.printERROR(_("wrong vars filter '%s'")\
cl_overriding.printERROR(_("wrong variable filter '%s'")\
%str(varsFilter))
cl_overriding.exit(1)
ret = {}

7
pym/cl_fill.py

@ -81,14 +81,14 @@ class fillVars(varsShare):
"""Get net domain name"""
textLines = self._runos("hostname -d 2>&1")
if textLines is False:
cl_overriding.printERROR(_("Error execute 'hostname -d'"))
cl_overriding.printERROR(_("Error executing 'hostname -d'"))
return cl_overriding.exit(1)
domain = ""
if textLines:
domain = textLines[0]
if not domain:
cl_overriding.printERROR(_("Error:") + " " +\
_("Not found domain name"))
_("Domain name not found"))
cl_overriding.printERROR(\
_("Command 'hostname -d' returns an empty value"))
return cl_overriding.exit(1)
@ -238,7 +238,8 @@ class fillVars(varsShare):
def get_hr_cdrom_set(self):
"""Cdrom variable"""
if os.path.exists('/sys/block/sr0'):
textLines = self._runos("udevadm info --query=all --name=/dev/dvdrw")
textLines = self._runos(
"udevadm info --query=all --name=/dev/dvdrw")
if not textLines is False:
for line in textLines:
if "ID_CDROM=1" in line:

2
pym/cl_ldap.py

@ -99,7 +99,7 @@ class ldapUser(_error):
dictData[name].append(line.rpartition(spl)[2].\
strip())
except:
#self.setError(_("Can not open %s")%fileName)
#self.setError(_("Failed to open %s")%fileName)
return False
if set(dictData.keys()) == set(namesData):
# Кеширование данных

17
pym/cl_opt.py

@ -278,23 +278,23 @@ class opt(optparse.OptionParser):
[{'longOption':"set",
'optVal':"VAR=VALUE",
'action':'append',
'help':_("set value for variable")
'help':_("set the variable value")
}]
variable_view = \
[{'shortOption':"v",
'longOption':"show-variables",
'action':'count',
'help':_("print variables, if the two options is verbose "
"(added print hidden variables)")
'help':_("print variables, in verbose mode if the two options "
"applied (includes printing hidden variables)")
},
{'longOption':"filter",
'optVal':"FILTER",
'help':_("filtered variables by regular expression, \
is used in conjunction with the options '-v --show-variables'")
'help':_("filter variables (as regexp, use *), to be used in"
" conjunction with options '-v --show-variables'")
},
{'longOption':"xml",
'help':_("output variables in the format of XML, \
is used in conjunction with the option '-v --show-variables'")
'help':_("output variables in XML format, to be used in"
" conjunction with options '-v --show-variables'")
}]
variable_control = variable_set + variable_view
@ -373,7 +373,8 @@ is used in conjunction with the option '-v --show-variables'")
should either exit or raise an exception.
"""
self.print_usage(sys.stderr)
self.exit(2, "%s: %s: %s\n%s\n" % (self.get_prog_name(), _("error"), msg,
self.exit(2, "%s: %s: %s\n%s\n" % (self.get_prog_name(),
_("error"), msg,
_("Try `%s' for more information")%
("%s --help"%self.get_prog_name())))

3
pym/cl_string.py

@ -344,7 +344,8 @@ class tableReport:
convLines.append(self._insertStrChar(lines[i], lenCols, char))
cl_overriding.printSUCCESS("\n".join(convLines))
if printRows:
cl_overriding.printSUCCESS("(%s %s)"%(len(self.dataList), _("rows")))
cl_overriding.printSUCCESS("(%s %s)"%
(len(self.dataList), _("rows")))
def _insertStrChar(self, line, lenCols, char):
"""Вставляет несколько символов char в указанные позиции

311
pym/cl_template.py

@ -332,7 +332,7 @@ class _terms(_error, _shareTermsFunction):
self.setError("'%s'"%rpl(term)+" "+\
_("incorrect"))
self.setError(\
_("Value function is not version"))
_("Function value is not version"))
return False
verFile, verVar = self._convertVers(vals[1],valVars)
res = dictRuleFunc[sepF](verVar,verFile)
@ -567,7 +567,7 @@ class fileHeader(_terms):
foundTerm = True
errorMsg = _("Incorrect template") +\
": "+ templateName +"\n"+\
_("header template not valid")+\
_("template header not valid")+\
": "+ i
if function:
rezTerm = self._equalTerm(i,
@ -714,7 +714,7 @@ class dirHeader(_terms):
foundTerm = True
errorMsg = _("Incorrect template") +\
": "+ templateName +"\n"+\
_("header template not valid")+ ": "+ i
_("template header not valid")+ ": "+ i
if function:
rezTerm = self._equalTerm(i, errorMsg,
function)
@ -2103,7 +2103,8 @@ class _file(_error):
try:
self.F_CONF.write(self.textConfig)
except:
self.setError(_("not open file:" ) + self.nameFileConfig)
self.setError(_("unable to open the file:" ) +
self.nameFileConfig)
return False
self.F_CONF.flush()
return True
@ -2114,7 +2115,7 @@ class _file(_error):
try:
F_TEMPL = open(nameFileTemplate, "r")
except:
self.setError(_("not open file:" ) + nameFileTemplate)
self.setError(_("unable to open the file:" ) + nameFileTemplate)
return False
return F_TEMPL
@ -2140,7 +2141,7 @@ class _file(_error):
try:
F_CONF = open(nameFileConfig, "w+")
except:
self.setError(_("not open file:" ) + nameFileConfig)
self.setError(_("unable to open the file:" ) + nameFileConfig)
return False
return F_CONF
@ -2396,7 +2397,7 @@ class _shareTemplate:
gid = pwdObj.pw_gid
homeDir = pwdObj.pw_dir
except:
cl_overriding.printERROR(_("Can not found user %s")%str(userName))
cl_overriding.printERROR(_("User %s not found")%str(userName))
cl_overriding.exit(1)
if groupsInfo:
import grp
@ -2404,7 +2405,7 @@ class _shareTemplate:
groupName = grp.getgrgid(gid).gr_name
except:
cl_overriding.printERROR(\
_("Can not found group id %s")%str(gid))
_("Id of group %s not found")%str(gid))
cl_overriding.exit(1)
groupsNames = map(lambda x: x.gr_name,\
filter(lambda x: userName in x.gr_mem, grp.getgrall()))
@ -2547,7 +2548,8 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
except:
self.printErrTemplate()
cl_overriding.printERROR(\
_("error var %s not int")%str(strNum))
_("error, variable %s not a number")%
str(strNum))
cl_overriding.exit(1)
elif self.objVar.exists(strNum):
try:
@ -2555,19 +2557,21 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
except:
self.printErrTemplate()
cl_overriding.printERROR(\
_("error var %s not int")%str(strNum))
_("error, variable %s not a number")%
str(strNum))
cl_overriding.exit(1)
else:
self.printErrTemplate()
cl_overriding.printERROR(\
_("error local var %s not defined")%str(strNum))
_("error, local variable %s is not defined")%
str(strNum))
cl_overriding.exit(1)
if minus:
num = -num
strNumers.append(num)
return sum(strNumers)
self.printErrTemplate()
cl_overriding.printERROR(_("error template term %s, incorrect data")\
cl_overriding.printERROR(_("error, template term %s, incorrect data")\
%str(term))
cl_overriding.exit(1)
@ -2634,7 +2638,7 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
else:
self.printErrTemplate()
cl_overriding.printERROR(\
_("Second argument function is not 'root'"))
_("The second argument of the function is not 'root'"))
cl_overriding.exit(1)
if fileName[0] == "~":
# Получаем директорию пользователя
@ -2679,14 +2683,14 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
else:
self.printErrTemplate()
cl_overriding.printERROR(\
_("Third argument function is not 'root'"))
_("The third argument of the function is not 'root'"))
cl_overriding.exit(1)
if lenTerms >= 2:
if not terms[0] in ["ver","num","char","key","empty"]:
self.printErrTemplate()
cl_overriding.printERROR(\
_("first argument function is not 'ver' or 'num' or 'char'"
" or 'empty'"))
_("the first argument of the function is not "
"'ver' or 'num' or 'char' or 'empty'"))
cl_overriding.exit(1)
if lenTerms == 1:
@ -2811,14 +2815,15 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
if not terms[0] in fArgvNames:
self.printErrTemplate()
cl_overriding.printERROR(\
_("first argument function must be 'num','pas' or 'uuid'"))
_("the first argument of the function "
"must be 'num','pas' or 'uuid'"))
cl_overriding.exit(1)
try:
lenStr = int(terms[1])
except:
self.printErrTemplate()
cl_overriding.printERROR(\
_("two argument function is not number"))
_("the second argument of the function is not a number"))
cl_overriding.exit(1)
choiceStr = fArgvNames[terms[0]]
replace = ''.join([random.choice(choiceStr) for i in xrange(lenStr)])
@ -2844,15 +2849,16 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
fArgvNames = ['upper','lower','capitalize']
if not terms[0] in fArgvNames:
self.printErrTemplate()
cl_overriding.printERROR(_("first argument function is not 'upper' \
or 'lower' or 'capitalize'"))
cl_overriding.printERROR(_("the first argument of the function is "
"not 'upper' or 'lower' or 'capitalize'"))
cl_overriding.exit(1)
try:
strValue = str(self.objVar.Get(terms[1]))
except:
cl_overriding.printERROR(_("error in template %s")\
%self.nameTemplate)
cl_overriding.printERROR(_("error var %s not found")%str(terms[1]))
cl_overriding.printERROR(_("error, variable %s not found")%
str(terms[1]))
cl_overriding.exit(1)
replace = ""
strValue = _toUNICODE(strValue)
@ -2892,14 +2898,14 @@ or 'lower' or 'capitalize'"))
self.stackGlobalVars.append(str(value))
else:
self.printErrTemplate()
cl_overriding.printERROR(_("error var %s exists")\
cl_overriding.printERROR(_("error, variable %s exists")\
%str(nameLocVar))
cl_overriding.exit(1)
else:
# Если переменная не существует
if len(terms) == 1:
self.printErrTemplate()
cl_overriding.printERROR(_("error var %s not exists")\
cl_overriding.printERROR(_("error, variable %s does not exist")\
%str(nameLocVar))
cl_overriding.exit(1)
elif len(terms) == 2:
@ -2929,7 +2935,7 @@ or 'lower' or 'capitalize'"))
else:
self.printErrTemplate()
cl_overriding.printERROR(\
_("error, gloval variables stack is empty"))
_("error, global variables stack is empty"))
cl_overriding.exit(1)
else:
self.printErrTemplate()
@ -3036,8 +3042,8 @@ or 'lower' or 'capitalize'"))
elif len(terms) == 3:
if not terms[2] in ['url','purl','unicode']:
self.printErrTemplate()
cl_overriding.printERROR(_("third argument function is not "
"'url' or 'purl' or 'unicode'"))
cl_overriding.printERROR(_("the third argument of the function"
" is not 'url' or 'purl' or 'unicode'"))
cl_overriding.exit(1)
if terms[1]:
self.printErrTemplate()
@ -3276,13 +3282,13 @@ or 'lower' or 'capitalize'"))
pass
if not flagFoundVar:
# Если переменная не существует
cl_overriding.printERROR(_("error var %s not exists")\
cl_overriding.printERROR(_("error, variable %s does not exist")\
%str(nameLocVar))
self.printErrTemplate()
cl_overriding.exit(1)
if not type(value) in (list,tuple):
# Значение переменной не список или кортеж
cl_overriding.printERROR(_("value of %s is not a list or tuple")\
cl_overriding.printERROR(_("value of %s is not a list or a tuple")\
%str(nameLocVar))
self.printErrTemplate()
cl_overriding.exit(1)
@ -3292,7 +3298,7 @@ or 'lower' or 'capitalize'"))
else:
replace = ""
except:
cl_overriding.printERROR(_("%s wrong")%strIndex)
cl_overriding.printERROR(_("wrong %s")%strIndex)
self.printErrTemplate()
cl_overriding.exit(1)
textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\
@ -3317,7 +3323,7 @@ or 'lower' or 'capitalize'"))
mountPoint = terms[0]
lastElementVar = terms[1]
if not mountPoint or mountPoint[:1] !="/":
cl_overriding.printERROR(_("%s wrong")%lastElementVar)
cl_overriding.printERROR(_("wrong %s")%lastElementVar)
self.printErrTemplate()
cl_overriding.exit(1)
nameVar = "os_install_disk_mount"
@ -3325,7 +3331,8 @@ or 'lower' or 'capitalize'"))
valueVar = self.objVar.Get(nameVar)
except:
# Если переменная не существует
cl_overriding.printERROR(_("error var %s not exists")%nameVar)
cl_overriding.printERROR(_("error, variable %s does not exist")%
nameVar)
self.printErrTemplate()
cl_overriding.exit(1)
nameElementVar = "os_install_disk_%s"%lastElementVar
@ -3337,20 +3344,20 @@ or 'lower' or 'capitalize'"))
try:
valueElementVar = self.objVar.Get(nameElementVar)
except:
cl_overriding.printERROR(_("%s wrong")%lastElementVar)
cl_overriding.printERROR(_("error var %s not exists")\
cl_overriding.printERROR(_("wrong %s")%lastElementVar)
cl_overriding.printERROR(_("error, variable %s does not exist")\
%nameElementVar)
self.printErrTemplate()
cl_overriding.exit(1)
if not type(valueVar) in (list,tuple):
# Значение переменной не список или кортеж
cl_overriding.printERROR(_("value of %s is not a list or tuple")\
cl_overriding.printERROR(_("value of %s is not a list or a tuple")\
%nameVar)
self.printErrTemplate()
cl_overriding.exit(1)
if not type(valueElementVar) in (list,tuple):
# Значение переменной не список или кортеж
cl_overriding.printERROR(_("value of %s is not a list or tuple")\
cl_overriding.printERROR(_("value of %s is not a list or a tuple")\
%nameElementVar)
self.printErrTemplate()
cl_overriding.exit(1)
@ -3371,8 +3378,8 @@ or 'lower' or 'capitalize'"))
index = num
break
if index is None:
cl_overriding.printERROR(_("in the value of the variable \
os_disk_install not found mount point '\' and '\%s'")%mountPoint)
cl_overriding.printERROR(_("mount point '\\' or '\\%s' not found "
"in the value of variable os_disk_install")%mountPoint)
self.printErrTemplate()
cl_overriding.exit(1)
replace = valueElementVar[index]
@ -3421,7 +3428,7 @@ os_disk_install not found mount point '\' and '\%s'")%mountPoint)
def printErrTemplate(self):
"""Печать ошибки при обработке функций шаблона"""
cl_overriding.printERROR(_("error in template %s")%self.nameTemplate)
cl_overriding.printERROR(_("error template term '%s'")\
cl_overriding.printERROR(_("error, template term '%s'")\
%str(self.functText))
def applyFuncTemplate(self, textTemplate, nameTemplate):
@ -3452,7 +3459,7 @@ os_disk_install not found mount point '\' and '\%s'")%mountPoint)
else:
self.printErrTemplate()
cl_overriding.printERROR(\
_("can not found template function '%s'")\
_("function of templates '%s' not found")\
%str(self.functText))
cl_overriding.exit(1)
@ -3539,7 +3546,7 @@ class template(_file,_terms,_warning,xmlShare,templateFormat,_shareTemplate):
self.__titleHead = "--------------------------------------\
----------------------------------------"
self._titleBody = ""
self._titleList = ("Modified", "Processed template files" + ":")
self._titleList = ("Modified", "Processing template files" + ":")
self._reVar = re.compile(("%s[a-zA-Z0-9_-]+%s")%(self.varStart,
self.varEnd),re.M)
# Условия
@ -3625,7 +3632,7 @@ re.M|re.S)
try:
res = string.atoi(strOct, 8)
except ValueError:
self.setError(_("Not valid oct value: ") + str(strOct))
self.setError(_("Invalid oct value: ") + str(strOct))
return False
return res
else:
@ -3664,7 +3671,7 @@ re.M|re.S)
try:
dUid,dGid = getModeFile(prevDir,"owner")
except OSError:
self.setError(_("Not access dir: " ) + prevDir)
self.setError(_("No access to the directory: " ) + prevDir)
return False
if not mode is False:
dMode = mode
@ -3682,7 +3689,8 @@ re.M|re.S)
os.mkdir(nameDir)
os.chown(nameDir, dUid, dGid)
except:
self.setError(_("Can not create dir: " ) + nameDir)
self.setError(_("Failed to create the directory: " ) +
nameDir)
return False
try:
if dMode:
@ -3693,7 +3701,7 @@ re.M|re.S)
os.chown(dirName, dUid, dGid)
createDirs.append(dirName)
except:
self.setError(_("Can not create dir: " ) + dirName)
self.setError(_("Failed to create the directory: " ) + dirName)
return False
return createDirs
@ -3735,7 +3743,7 @@ re.M|re.S)
parent = ""
term = resS.group("rTerm") + parent +\
resS.group("lTerm")
if self._equalTerm(term, _("content template not valid: ")+\
if self._equalTerm(term, _("invalid template content: ")+\
nameTemplate, function):
textTemplateTmp = textTemplateTmp.replace(mark, body+end)
else:
@ -3752,7 +3760,7 @@ re.M|re.S)
if len(spFile)>1:
flagTrue = False
for term in spFile[1:]:
if self._equalTerm(term, _("name template not valid: ")+\
if self._equalTerm(term, _("invalid template name: ")+\
fileTemplate):
flagTrue = True
break
@ -3763,7 +3771,7 @@ re.M|re.S)
else:
return True
else:
self.setError(_("name template not valid: ")+ str(fileTemplate))
self.setError(_("invalid template name: ")+ str(fileTemplate))
return False
def getTitle(self, comment, commentList, configPath=""):
@ -3905,24 +3913,24 @@ re.M|re.S)
setWARNING = lambda x: self.setWarning(x) and\
self.printWarning and\
printObj.printWARNING(x)
setWARNING(_("No conditions of checking a value of the \
variable 'cl_name'"))
setWARNING(_("No conditions of checking the value of "
"variable 'cl_name'"))
skipDirTemplates = []
for skipDir in skipDirs:
skipTempl = os.path.join(skipDir,self.templDirNameFile)
if os.path.isfile(skipTempl):
skipDirTemplates.append(skipTempl)
if skipTemplates or skipDirTemplates:
setWARNING(_("Skip templates:"))
setWARNING(_("Skipped templates:"))
for skipTemplate in skipTemplates + skipDirTemplates:
setWARNING(" "*6 + skipTemplate)
if skipDirs:
setWARNING(_("Skip directories:"))
setWARNING(_("Skipped directories:"))
for skipDir in skipDirs:
setWARNING(" "*6 + skipDir)
setWARNING("")
setWARNING(_("Headers directory and template files first level "\
"should include of the 'cl_name' variable."))
setWARNING(_("Headers of directory templates and headers of files "
"on the first level should include 'cl_name' variable."))
setWARNING(_("Example:"))
setWARNING("# Calculate cl_name==calculate-install")
return skipDirs + skipTemplates
@ -3949,7 +3957,7 @@ variable 'cl_name'"))
return dictTemplates
if not self.objVar.defined("cl_template_path"):
self.setError(_("not defined Var: ") + "cl_template_path")
self.setError(_("undefined variable: ") + "cl_template_path")
return False
dirsTemplates = self.objVar.Get("cl_template_path")
dirsTemplates.sort()
@ -4214,7 +4222,7 @@ variable 'cl_name'"))
textTemplate = FD.read()
FD.close()
except:
self.setError(_("Error open template") + ": " +\
self.setError(_("Error in opening template") + ": " +\
templateDirFile)
return ("", False, [])
@ -4245,7 +4253,7 @@ variable 'cl_name'"))
path = os.path.join(self.homeDir,
path.partition("/")[2],"")[:-1]
elif not path or path and path[0] != "/":
self.setError(_("False value 'path' in template") + ": " +\
self.setError(_("Wrong value 'path' in the template") + ": " +\
templateDirFile)
return ("", False, [])
else:
@ -4255,7 +4263,7 @@ variable 'cl_name'"))
if "name" in objHead.params:
nameDir = objHead.params['name']
if "/" in nameDir or nameDir == ".." or nameDir == ".":
self.setError(_("False value 'name' in template") + ": " +\
self.setError(_("Wrong value 'name' in the template") + ": " +\
templateDirFile)
return ("", False, [])
# Новый путь к директории
@ -4274,7 +4282,7 @@ variable 'cl_name'"))
try:
removeDir(applyDir)
except:
self.setError(_("Can not delete dir: " ) +\
self.setError(_("Failed to delete the directory: " ) +\
applyDir)
return ("", False, [])
@ -4288,13 +4296,14 @@ variable 'cl_name'"))
try:
removeDir(removePath)
except:
self.setError(_("Can not delete dir: " ) +\
self.setError(
_("Failed to delete the directory: ") +\
removePath)
else:
try:
os.unlink(removePath)
except:
self.setError(_("Can not delete: " ) + removePath)
self.setError(_("Failed to delete: " ) + removePath)
return ("", False, [])
# Созданные директории
@ -4312,7 +4321,7 @@ variable 'cl_name'"))
else:
os.chmod(applyDir, mode)
else:
self.setError(_("False value 'chmod' in template") + ": " +\
self.setError(_("Wrong value 'chmod' in the template") + ": " +\
templateDirFile)
return ("", False, [])
# chown - изменяем владельца и группу
@ -4326,8 +4335,9 @@ variable 'cl_name'"))
try:
uid = pwd.getpwnam(strUid).pw_uid
except:
self.setError(_("Not user in this system: ") + strUid)
self.setError(_("False value 'chown' in template")+\
self.setError(_("No such user on the system: ")
+ strUid)
self.setError(_("Wrong value 'chown' in the template")+\
": " + templateDirFile)
return ("", False, [])
gid = self.getGidFromGroup(strGid)
@ -4335,8 +4345,9 @@ variable 'cl_name'"))
import grp
gid = grp.getgrnam(strGid).gr_gid
except:
self.setError(_("Not group in this system: ")+strGid)
self.setError(_("False value 'chown' in template") +\
self.setError(_("Group not found on the system: ")
+strGid)
self.setError(_("Wrong value 'chown' in the template")+\
": "+ templateDirFile)
return ("", False, [])
@ -4351,11 +4362,11 @@ variable 'cl_name'"))
templateDirFile):
return ("", False, [])
else:
self.setError(_("False value 'chown' in template") + ": " +\
templateDirFile)
self.setError(_("Wrong value 'chown' in the template") +
": " + templateDirFile)
return ("", False, [])
else:
self.setError(_("False value 'chown' in template") + ": " +\
self.setError(_("Wrong value 'chown' in the template") + ": " +\
templateDirFile)
return ("", False, [])
else:
@ -4472,7 +4483,7 @@ variable 'cl_name'"))
self.nameFileTemplate = os.path.abspath(nameFileTemplate)
self.F_TEMPL = self.openTemplFile(self.nameFileTemplate)
if not self.F_TEMPL:
self.setError(_("Error open template") + ": " +\
self.setError(_("Error in opening template") + ": " +\
templateDirFile)
return False
self.textTemplate = self.F_TEMPL.read()
@ -4496,7 +4507,7 @@ variable 'cl_name'"))
# Получаем путь с заменой ~ на директорию пользователя
path = os.path.join(self.homeDir,path.partition("/")[2],"")[:-1]
elif not path or path and path[0] != "/":
self.setError(_("False value 'path' in template") + ": " +\
self.setError(_("Wrong value 'path' in the template") + ": " +\
nameFileTemplate)
return ([], False)
else:
@ -4507,7 +4518,7 @@ variable 'cl_name'"))
if objHeadNew.params.has_key("name"):
nameFile = objHeadNew.params['name']
if "/" in nameFile or nameFile == ".." or nameFile == ".":
self.setError(_("False value 'name' in template") + ": " +\
self.setError(_("Wrong value 'name' in the template") + ": " +\
nameFileTemplate)
return ([], False)
# Новый путь к оригинальному файлу
@ -4525,13 +4536,13 @@ variable 'cl_name'"))
if "exec" in objHeadNew.params:
execPath = objHeadNew.params['exec']
if not os.access(execPath,os.X_OK):
self.setError(_("False value 'exec' in template") + ": " +\
self.setError(_("Wrong value 'exec' in the template") + ": " +\
nameFileTemplate)
self.setError(_("Can not execute %s") %execPath)
self.setError(_("Failed to execute %s") %execPath)
return ([], False)
if typeAppendTemplate == "join":
self.setError(_("False value 'append=join' in template") + ": " +\
nameFileTemplate)
self.setError(_("Wrong value 'append=join' in the template") +\
": " + nameFileTemplate)
return ([], False)
# Очищаем оригинальный файл
@ -4539,9 +4550,9 @@ variable 'cl_name'"))
try:
open(pathOldFile, "w").truncate(0)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not clear file") + ": " +\
self.setError(_("Failed to clear the file") + ": " +\
pathOldFile)
return (applyFiles, False)
# Удаляем оригинальный файл
@ -4551,9 +4562,9 @@ variable 'cl_name'"))
try:
os.unlink(pathOldFile)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not delete link") + ": " +\
self.setError(_("Failed to delete the link") + ": " +\
pathOldFile)
return ([], False)
if os.path.isfile(pathOldFile):
@ -4561,9 +4572,9 @@ variable 'cl_name'"))
try:
os.remove(pathOldFile)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not delete file") + ": " +\
self.setError(_("Failed to delete the file") + ": " +\
pathOldFile)
return ([], False)
return (applyFiles, False)
@ -4582,9 +4593,9 @@ variable 'cl_name'"))
try:
os.unlink(pathOldFile)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not delete link") + ": " +\
self.setError(_("Failed to delete the link") + ": " +\
pathOldFile)
return ([], False)
if os.path.isfile(pathOldFile):
@ -4592,9 +4603,9 @@ variable 'cl_name'"))
try:
os.remove(pathOldFile)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not delete file") + ": " +\
self.setError(_("Failed to delete the file") + ": " +\
pathOldFile)
return ([], False)
@ -4610,10 +4621,10 @@ variable 'cl_name'"))
try:
os.remove(pathOldFile)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not delete file") + ": " +\
pathOldFile)
self.setError(_("Failed to delete the file") + \
": " + pathOldFile)
return ([], False)
elif not os.path.exists(pathOldFile):
return ([], False)
@ -4630,18 +4641,18 @@ variable 'cl_name'"))
F_CONF.close()
fMode, fUid, fGid = getModeFile(templateFile)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not open file") + ": " +\
self.setError(_("Failed to open the file") + ": " +\
templateFile)
return ([], False)
if os.path.exists(pathOldFile):
try:
os.remove(pathOldFile)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not delete file") + ": " +\
self.setError(_("Failed to delete the file") + ": " +\
pathOldFile)
return ([], False)
if foundTemplateFile:
@ -4650,9 +4661,9 @@ variable 'cl_name'"))
FD.write(buff)
FD.close()
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not create file") + " '%s'"\
self.setError(_("Failed to create the file") + " '%s'"\
%pathOldFile)
return ([], False)
oMode = getModeFile(pathOldFile, mode="mode")
@ -4673,9 +4684,10 @@ variable 'cl_name'"))
try:
os.chdir(pathLink)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not change the current directory to")+\
self.setError(
_("Failed to change the current directory to")+\
" " + pathLink)
return ([], False)
@ -4687,7 +4699,7 @@ variable 'cl_name'"))
preReturn(pathProg)
return ([], False)
else:
self.setError(_("False value 'chmod' in template") + ": " +\
self.setError(_("Wrong value 'chmod' in the template") + ": " +\
nameFileTemplate)
preReturn(pathProg)
return ([], False)
@ -4706,9 +4718,10 @@ variable 'cl_name'"))
if uid is None:
uid = pwd.getpwnam(strUid).pw_uid
except:
self.setError(_("Not user in this system: ") +
self.setError(_("No such user on the system: ") +
strUid)
self.setError(_("False value 'chown' in template") +
self.setError(
_("Wrong value 'chown' in the template") +
": "+ nameFileTemplate)
preReturn(pathProg)
return ([], False)
@ -4721,9 +4734,10 @@ variable 'cl_name'"))
import grp
gid = grp.getgrnam(strGid).gr_gid
except:
self.setError(_("Not group in this system: ") +
self.setError(_("Group not found on the system: ") +
strGid)
self.setError(_("False value 'chown' in template") +
self.setError(
_("Wrong value 'chown' in the template") +
": "+ nameFileTemplate)
preReturn(pathProg)
return ([], False)
@ -4732,12 +4746,12 @@ variable 'cl_name'"))
preReturn(pathProg)
return ([], False)
else:
self.setError(_("False value 'chown' in template") + ": " +\
nameFileTemplate)
self.setError(_("Wrong value 'chown' in the template") +
": " + nameFileTemplate)
preReturn(pathProg)
return ([], False)
else:
self.setError(_("False value 'chown' in template") + ": " +\
self.setError(_("Wrong value 'chown' in the template") + ": " +\
nameFileTemplate)
preReturn(pathProg)
return ([], False)
@ -4766,9 +4780,9 @@ variable 'cl_name'"))
# иначе удаляем файл
os.remove(prevOldFile)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not delete file") + ": " +\
self.setError(_("Failed to delete the file") + ": " +\
prevOldFile)
preReturn(pathProg)
return ([], False)
@ -4779,9 +4793,9 @@ variable 'cl_name'"))
try:
os.symlink(pathOldFile, prevOldFile)
except:
self.setError(_("Error in template") + ": " +\
self.setError(_("Template error") + ": " +\
nameFileTemplate)
self.setError(_("Can not create symbolic link") + " :" +\
self.setError(_("Failed to create a symbolic link") + " :" +\
"%s -> %s"%(prevOldFile, pathOldFile))
preReturn(pathProg)
return ([], False)
@ -4928,22 +4942,22 @@ variable 'cl_name'"))
if formatTemplate == "patch":
if typeAppendTemplate != "patch":
self.setError(\
_("False option append=%(type)s in template %(file)s")\
_("Wrong option append=%(type)s in template %(file)s")\
%{"type":typeAppendTemplate,"file":nameFileTemplate})
return False
# создаем объект формата шаблона
objTempl = self.getFormatObj(formatTemplate, self.textTemplate)
if not objTempl:
self.setError(\
_("Incorrect header parmeter format=%s in template")\
%formatTemplate + " " + nameFileTemplate)
_("Incorrect header parmeter format=%s in the template")\
%formatTemplate + " " + nameFileTemplate)
return False
if objHeadOld and objHeadOld.body:
self.textConfig = objHeadOld.body
# обработка конфигурационного файла
self.textTemplate = objTempl.processingFile(self.textConfig)
if objTempl.getError():
self.setError(_("False template") + ": " +\
self.setError(_("Wrong template") + ": " +\
nameFileTemplate)
return False
if execStr:
@ -4954,9 +4968,9 @@ variable 'cl_name'"))
if 'exec' in objHeadNew.params:
if not self.executeTemplate(self.nameFileConfig,
objHeadNew.params['exec']):
self.setError(_("False template") + ": " +\
self.setError(_("Wrong template") + ": " +\
nameFileTemplate)
self.setError(_("Can not execute") + ": " +\
self.setError(_("Failed to execute") + ": " +\
self.nameFileConfig)
return False
return False
@ -4976,12 +4990,12 @@ variable 'cl_name'"))
self.textTemplate)
if not objTemplNew:
self.setError(\
_("Incorrect header parmeter format=%s in template")\
%formatTemplate + " " + nameFileTemplate)
_("Incorrect header parmeter format=%s in the template")\
%formatTemplate + " " + nameFileTemplate)
return False
if "xml_" in formatTemplate:
if objTemplNew.getError():
self.setError(_("False template") + ": " +\
self.setError(_("Wrong template") + ": " +\
nameFileTemplate)
return False
# Имя файла внутри xml xfce конфигурационных файлов
@ -5026,9 +5040,9 @@ variable 'cl_name'"))
if 'exec' in objHeadNew.params:
if not self.executeTemplate(self.nameFileConfig,
objHeadNew.params['exec']):
self.setError(_("False template") + ": " +\
self.setError(_("Wrong template") + ": " +\
nameFileTemplate)
self.setError(_("Can not execute") + ": " +\
self.setError(_("Failed to execute") + ": " +\
self.nameFileConfig)
return False
return False
@ -5037,7 +5051,7 @@ variable 'cl_name'"))
elif typeAppendTemplate == "before":
if "xml_" in formatTemplate:
self.setError(\
_("False option append=before in template %s")\
_("Wrong option append=before in template %s")\
%nameFileTemplate)
return False
if objHeadOld and objHeadOld.body:
@ -5055,9 +5069,9 @@ variable 'cl_name'"))
if 'exec' in objHeadNew.params:
if not self.executeTemplate(self.nameFileConfig,
objHeadNew.params['exec']):
self.setError(_("False template") + ": " +\
self.setError(_("Wrong template") + ": " +\
nameFileTemplate)
self.setError(_("Can not execute") + ": " +\
self.setError(_("Failed to execute") + ": " +\
self.nameFileConfig)
return False
return False
@ -5066,7 +5080,7 @@ variable 'cl_name'"))
elif typeAppendTemplate == "after":
if "xml_" in formatTemplate:
self.setError(\
_("False option append=after in template %s")\
_("Wrong option append=after in template %s")\
%nameFileTemplate)
return False
if objHeadOld and objHeadOld.body:
@ -5083,9 +5097,9 @@ variable 'cl_name'"))
if 'exec' in objHeadNew.params:
if not self.executeTemplate(self.nameFileConfig,
objHeadNew.params['exec']):
self.setError(_("False template") + ": " +\
self.setError(_("Wrong template") + ": " +\
nameFileTemplate)
self.setError(_("Can not execute") + ": " +\
self.setError(_("Failed to execute") + ": " +\
self.nameFileConfig)
return False
return False
@ -5097,20 +5111,20 @@ variable 'cl_name'"))
self.textTemplate = objTxtCoder.encode(self.textTemplate)
if formatTemplate =="raw":
self.setError(\
_("Incorrect header parmeter append=%s in template")\
%typeAppendTemplate + " " + nameFileTemplate)
_("Incorrect header parmeter append=%s in the template")\
%typeAppendTemplate + " " + nameFileTemplate)
return False
# создаем объект формата шаблона
objTemplNew = self.getFormatObj(formatTemplate,
self.textTemplate)
if not objTemplNew:
self.setError(\
_("Incorrect header parmeter format=%s in template")\
%formatTemplate + " " + nameFileTemplate)
_("Incorrect header parmeter format=%s in the template")\
%formatTemplate + " " + nameFileTemplate)
return False
if "xml_" in formatTemplate:
if objTemplNew.getError():
self.setError(_("False template") + ": " +\
self.setError(_("Wrong template") + ": " +\
nameFileTemplate)
return False
nameRootNode=nameFileConfig.rpartition("/")[2].split(".")[0]
@ -5145,7 +5159,7 @@ variable 'cl_name'"))
return False
if "xml_" in formatTemplate:
if objTemplOld.getError():
self.setError(_("False template") + ": " +\
self.setError(_("Wrong template") + ": " +\
nameFileConfig)
return False
nameRootNode=nameFileConfig.rpartition("/")[2].split(".")[0]
@ -5154,7 +5168,7 @@ variable 'cl_name'"))
objTemplOld.join(objTemplNew)
if "xml_" in formatTemplate:
if objTemplOld.getError():
self.setError(_("False template") + ": " +\
self.setError(_("Wrong template") + ": " +\
nameFileTemplate)
return False
data = objTemplOld.getConfig().encode("UTF-8").split("\n")
@ -5175,19 +5189,19 @@ variable 'cl_name'"))
if 'exec' in objHeadNew.params:
if not self.executeTemplate(self.nameFileConfig,
objHeadNew.params['exec']):
self.setError(_("False template") + ": " +\
self.setError(_("Wrong template") + ": " +\
nameFileTemplate)
self.setError(_("Can not execute") + ": " +\
self.setError(_("Failed to execute") + ": " +\
self.nameFileConfig)
return False
return False
return filesApply
else:
self.setError(_("False (type append) template") + ": " +\
self.setError(_("Wrong (type append) template") + ": " +\
typeAppendTemplate)
return False
else:
self.setError(_("Type template not found: ") + nameFileTemplate)
self.setError(_("Template type not found: ") + nameFileTemplate)
return False
return filesApply
@ -5325,7 +5339,7 @@ class templateClt(scanDirectoryClt, template):
if not self.flagApplyTemplates:
return ([],[])
if not self.objVar.defined("cl_template_clt_path"):
self.setError(_("not defined Var: ") + "cl_template_clt_path")
self.setError(_("undefined variable: ") + "cl_template_clt_path")
return False
dirsTemplates = self.objVar.Get("cl_template_clt_path")
dirsTemplates.sort()