Fix print messages from stderr. Fix delete template vars. Fix server.ldap module (Can't import module 'ldap').

develop
Самоукин Алексей 14 years ago
parent 133ba00dad
commit e52d9ec12a

@ -413,14 +413,19 @@ storage of variables templates")%location)
if not header: if not header:
header = self.__getSection(vname) header = self.__getSection(vname)
# Удаляем переменную # Удаляем переменную
retDelVar = config.delVar(header, vname) allVars = config.getAreaVars(header)
retDelArea = True if allVars is False:
if not config.getAreaVars(header):
retDelArea = config.delArea(header)
if retDelArea and retDelVar:
return True
else:
return 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): def Write(self,vname,val=None,force=False,location='default',header=False):
'''Установить и записать значение переменной в ini файл '''Установить и записать значение переменной в ini файл

@ -24,7 +24,7 @@ class color_print(object):
def getconsolewidth(self): def getconsolewidth(self):
"""Получить ширину текущей консоли""" """Получить ширину текущей консоли"""
s = struct.pack("HHHH", 0, 0, 0, 0) s = struct.pack("HHHH", 0, 0, 0, 0)
fd_stdout = sys.stdout.fileno() fd_stdout = self._printSysOut.fileno()
try: try:
x = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, s) x = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, s)
except IOError: except IOError:
@ -40,7 +40,7 @@ class color_print(object):
""" """
cols = self.getconsolewidth() cols = self.getconsolewidth()
for i in range(cols - offsetLeft - offsetRight): for i in range(cols - offsetLeft - offsetRight):
sys.stdout.write(" ") self._printSysOut.write(" ")
def colorPrint(self,attr,fg,bg,string): def colorPrint(self,attr,fg,bg,string):
"""Раскрашивает выводимое сообщение """Раскрашивает выводимое сообщение

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import ldap as mod_ldap

@ -15,8 +15,12 @@
# limitations under the License. # limitations under the License.
import os import os
import ldap from mod import mod_ldap
from ldap import LDAPError, MOD_REPLACE, MOD_ADD, SCOPE_SUBTREE, SCOPE_ONELEVEL 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 from ldif import LDIFParser, LDIFWriter
import cStringIO, StringIO import cStringIO, StringIO
from cl_utils import _error from cl_utils import _error

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import sys import sys, os
from cl_print import color_print from cl_print import color_print
from cl_datavars import DataVars from cl_datavars import DataVars
@ -44,12 +44,13 @@ class services(color_print):
def allServicesApi(self): def allServicesApi(self):
self.createClLibVars(clLibVars=self.clLibVars) self.createClLibVars(clLibVars=self.clLibVars)
apiDict = self.clLibVars.Get('cl_api') 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 [] return []
apiFiles = apiDict.keys() apiFiles = apiDict.values()
apiObjects = [] apiObjects = []
for apiFile in apiFiles: for apiFile in apiFiles:
importPath, moduleName = os.path.split(apiFile) importPath, moduleName = os.path.split(apiFile)
moduleName = moduleName.rpartition(".py")[0]
if not importPath in sys.path: if not importPath in sys.path:
sys.path.insert(0, importPath) sys.path.insert(0, importPath)
try: try:
@ -71,9 +72,9 @@ class services(color_print):
def runMethodToAllServices(self, methodName, sortedServices="normal"): def runMethodToAllServices(self, methodName, sortedServices="normal"):
"""Stopped all setup services""" """Stopped all setup services"""
allServObjs = self.allServicesApi() allServObjs = self.allServicesApi()
allSetupServObjs = filter(lambda x: x.isSetup(), allServObjs)
if allServObjs is False: if allServObjs is False:
return False return False
allSetupServObjs = filter(lambda x: x.isSetup(), allServObjs)
def smpPrioritetReverse(objectA, objectB): def smpPrioritetReverse(objectA, objectB):
'''Comparison of the run priorities of objects '''Comparison of the run priorities of objects

@ -108,7 +108,7 @@ def rawInput(promptText="", inputText=""):
readline.set_pre_input_hook(None) readline.set_pre_input_hook(None)
return strInput return strInput
def execProg(self, cmdStrProg, inStr=False, envProg={}): def execProg(cmdStrProg, inStr=False, envProg={}):
"""Выполняет внешнюю программу """Выполняет внешнюю программу
Параметры: Параметры:

@ -68,7 +68,8 @@ setup(
'calculate-lib.pym.format', 'calculate-lib.pym.format',
'calculate-lib.pym.server', 'calculate-lib.pym.server',
'calculate-lib.pym.client', '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']), data_files = [("/usr/share/calculate/i18n",['i18n/cl_lib_ru.mo']),
("/var/calculate/remote", []), ("/var/calculate/remote", []),
("/var/log/calculate", [])], ("/var/log/calculate", [])],

Loading…
Cancel
Save