From a67f6ba0d25c84aa16717e08236ca79e65dc3cde 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: Mon, 27 Sep 2010 17:17:38 +0400 Subject: [PATCH] Add template function exec(). --- pym/cl_template.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pym/cl_template.py b/pym/cl_template.py index edb05b8..9d4aac9 100644 --- a/pym/cl_template.py +++ b/pym/cl_template.py @@ -25,13 +25,15 @@ import types import random import string import time +import glob # Переопределение exit import cl_overriding from cl_utils import _error, _warning, _toUNICODE, getModeFile, removeDir,\ - typeFile, scanDirectory, convertStrListDict, pathJoin + typeFile, scanDirectory, convertStrListDict, pathJoin,\ + runOsCommand import cl_lang tr = cl_lang.lang() @@ -2268,7 +2270,6 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction): # Текст функции шаблона functText = "" - def __init__(self, objVar): # Если не определен словарь функций шаблона if not self.templateFunction: @@ -3125,6 +3126,21 @@ os_disk_install not found mount point '\' and '\%s'")%mountPoint) textTemplateTmp[resS.end():] return textTemplateTmp + def funcExec(self, funArgv, resS, localVars, textTemplateTmp): + """Функция шаблона exec(). + + Выполняет первый аргумент, при ошибке результат "" иначе "1" + """ + retCode, outMess = runOsCommand(funArgv) + print outMess + if retCode == 0: + replace = "1" + else: + replace = "" + textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\ + textTemplateTmp[resS.end():] + return textTemplateTmp + def printErrTemplate(self): """Печать ошибки при обработке функций шаблона""" cl_overriding.printERROR(_("error in template %s")%self.nameTemplate)