diff --git a/pym/cl_datavars.py b/pym/cl_datavars.py index 7e7207a..e01063e 100644 --- a/pym/cl_datavars.py +++ b/pym/cl_datavars.py @@ -413,14 +413,19 @@ storage of variables templates")%location) if not header: header = self.__getSection(vname) # Удаляем переменную - retDelVar = config.delVar(header, vname) - retDelArea = True - if not config.getAreaVars(header): - retDelArea = config.delArea(header) - if retDelArea and retDelVar: - return True - else: + allVars = config.getAreaVars(header) + if allVars is False: return False + if vname in allVars.keys(): + retDelVar = config.delVar(header, vname) + retDelArea = True + if not config.getAreaVars(header): + retDelArea = config.delArea(header) + if retDelArea and retDelVar: + return True + else: + return False + return True def Write(self,vname,val=None,force=False,location='default',header=False): '''Установить и записать значение переменной в ini файл diff --git a/pym/cl_print.py b/pym/cl_print.py index e094ffa..8d14edd 100644 --- a/pym/cl_print.py +++ b/pym/cl_print.py @@ -24,7 +24,7 @@ class color_print(object): def getconsolewidth(self): """Получить ширину текущей консоли""" s = struct.pack("HHHH", 0, 0, 0, 0) - fd_stdout = sys.stdout.fileno() + fd_stdout = self._printSysOut.fileno() try: x = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, s) except IOError: @@ -40,7 +40,7 @@ class color_print(object): """ cols = self.getconsolewidth() for i in range(cols - offsetLeft - offsetRight): - sys.stdout.write(" ") + self._printSysOut.write(" ") def colorPrint(self,attr,fg,bg,string): """Раскрашивает выводимое сообщение diff --git a/pym/mod/__init__.py b/pym/mod/__init__.py new file mode 100644 index 0000000..bae4e02 --- /dev/null +++ b/pym/mod/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import ldap as mod_ldap \ No newline at end of file diff --git a/pym/server/__init__.py b/pym/server/__init__.py index 8d1c8b6..e69de29 100644 --- a/pym/server/__init__.py +++ b/pym/server/__init__.py @@ -1 +0,0 @@ - diff --git a/pym/server/ldap.py b/pym/server/ldap.py index bc1635a..e50a85f 100644 --- a/pym/server/ldap.py +++ b/pym/server/ldap.py @@ -15,8 +15,12 @@ # limitations under the License. import os -import ldap -from ldap import LDAPError, MOD_REPLACE, MOD_ADD, SCOPE_SUBTREE, SCOPE_ONELEVEL +from mod import mod_ldap +import sys +sys.modules['mod_ldap'] = mod_ldap + +from mod_ldap import LDAPError, MOD_REPLACE, MOD_ADD, SCOPE_SUBTREE,\ + SCOPE_ONELEVEL from ldif import LDIFParser, LDIFWriter import cStringIO, StringIO from cl_utils import _error diff --git a/pym/server/services.py b/pym/server/services.py index 70d4b00..f29fc84 100644 --- a/pym/server/services.py +++ b/pym/server/services.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys +import sys, os from cl_print import color_print from cl_datavars import DataVars @@ -44,12 +44,13 @@ class services(color_print): def allServicesApi(self): self.createClLibVars(clLibVars=self.clLibVars) apiDict = self.clLibVars.Get('cl_api') - if not apiDict or not type(apiDict) in dict: + if not apiDict or not type(apiDict) is dict: return [] - apiFiles = apiDict.keys() + apiFiles = apiDict.values() apiObjects = [] for apiFile in apiFiles: importPath, moduleName = os.path.split(apiFile) + moduleName = moduleName.rpartition(".py")[0] if not importPath in sys.path: sys.path.insert(0, importPath) try: @@ -71,9 +72,9 @@ class services(color_print): def runMethodToAllServices(self, methodName, sortedServices="normal"): """Stopped all setup services""" allServObjs = self.allServicesApi() - allSetupServObjs = filter(lambda x: x.isSetup(), allServObjs) if allServObjs is False: return False + allSetupServObjs = filter(lambda x: x.isSetup(), allServObjs) def smpPrioritetReverse(objectA, objectB): '''Comparison of the run priorities of objects diff --git a/pym/server/utils.py b/pym/server/utils.py index 981da5e..018ec8a 100644 --- a/pym/server/utils.py +++ b/pym/server/utils.py @@ -108,7 +108,7 @@ def rawInput(promptText="", inputText=""): readline.set_pre_input_hook(None) return strInput -def execProg(self, cmdStrProg, inStr=False, envProg={}): +def execProg(cmdStrProg, inStr=False, envProg={}): """Выполняет внешнюю программу Параметры: diff --git a/setup.py b/setup.py index 338fcdc..f42dded 100755 --- a/setup.py +++ b/setup.py @@ -68,7 +68,8 @@ setup( 'calculate-lib.pym.format', 'calculate-lib.pym.server', 'calculate-lib.pym.client', - 'calculate-lib.pym.update_config'], + 'calculate-lib.pym.update_config', + 'calculate-lib.pym.mod'], data_files = [("/usr/share/calculate/i18n",['i18n/cl_lib_ru.mo']), ("/var/calculate/remote", []), ("/var/log/calculate", [])],