Browse Source

Bugfix

tags/3.5.0_alpha1
Самоукин Алексей 10 years ago
parent
commit
c581d489b9
2 changed files with 38 additions and 13 deletions
  1. +0
    -1
      pym/cl_ldap_api.py
  2. +38
    -12
      pym/cl_ldap_service.py

+ 0
- 1
pym/cl_ldap_api.py View File

@@ -47,7 +47,6 @@ class Template:
else:
return dirsFiles


class shareVars:
"""share methods template vars"""
# template variables


+ 38
- 12
pym/cl_ldap_service.py View File

@@ -28,7 +28,6 @@ from server.utils import genSleep
from cl_utils import removeDir, _error, appendProgramToEnvFile,\
removeProgramToEnvFile

import cl_overriding
from cl_lang import lang
lang().setLanguage(sys.modules[__name__])

@@ -39,18 +38,39 @@ class ldapService(shareVars, shareldap, Template):
apiFile = '/usr/lib/calculate-2.2/calculate-ldap/pym/cl_ldap_api.py'
APIObj = serviceAPI()
libAPIObj = packagesAPI()
flagError = False

def isError(self):
return self.flagError

def removeLdapDatabase(self):
"""Удаляем предыдущую базу данных"""
pathDatabase = "/var/lib/openldap-data"
if os.path.exists(pathDatabase) and os.listdir(pathDatabase):
if os.system("rm /var/lib/openldap-data/* &>/dev/null") !=0:
self.printERROR("Can't remove /var/lib/openldap-data/*")
return False
return True
# TEST
if os.path.exists(pathDatabase) and os.listdir(pathDatabase):
removeDir(pathDatabase)
#if os.path.exists(pathDatabase) and os.listdir(pathDatabase):
#if os.system("rm /var/lib/openldap-data/* &>/dev/null") !=0:
#self.printERROR("Can't remove /var/lib/openldap-data/*")
#return False
#return True
if os.path.exists(pathDatabase):
fileOrDirNames = os.listdir(pathDatabase)
if fileOrDirNames:
for fileOrDirName in fileOrDirNames:
fullFileOrDirName = os.path.join(pathDatabase,
fileOrDirName)
if os.path.isdir(fullFileOrDirName):
try:
removeDir(pathDatabase)
except:
self.printERROR(_("Can't remove directory %s")\
%fullFileOrDirName)
return False
else:
try:
os.remove(fullFileOrDirName)
except:
self.printERROR(_("Can't remove file %s")\
%fullFileOrDirName)
return False
self.printOK(_("Erased LDAP Database") + " ...")
return True

@@ -58,9 +78,11 @@ class ldapService(shareVars, shareldap, Template):
try:
value = eval('self.libAPIObj.%s'%attr)
except APIError, e:
self.flagError = True
self.printERROR(str(e))
cl_overriding.exit(1)
return False
except Exception, e:
self.flagError = True
self.printERROR(str(e))
return False
return value
@@ -161,7 +183,11 @@ class ldapService(shareVars, shareldap, Template):
# Удаляем из автозапуска демона
if not self.APIObj.del_runlevel():
return False
if self.getApiAttrLib("calculate_ldap") == False and self.isError():
self.printERROR(_("Can not found API module in package "
"calculate-ldap"))
self.printWARNING(_("Run: cl-ldap-setup --install"))
return False
# Останавливаем все установленные сервисы
if not self.getApiAttrLib("all.stop"):
return False
@@ -238,7 +264,7 @@ class ldapService(shareVars, shareldap, Template):
self.clVars.Write("sr_ldap_set","on",force=True)
self.printOK(_("LDAP service configured") + " ...")
# test
print self.getApiAttrLib("calculate_ldap.apply_templates")
# print self.getApiAttrLib("calculate_ldap.apply_templates")
return True
def printVars(self, *arg, **argv):


Loading…
Cancel
Save