Browse Source

Bugfix create symbolic link to directory.

Modified api module.
develop
Самоукин Алексей 11 years ago
parent
commit
b5ed0efaa0
  1. 31
      pym/cl_abstract.py
  2. 19
      pym/cl_api.py
  3. 4
      pym/cl_template.py

31
pym/cl_abstract.py

@ -1,34 +1,34 @@
# -*- coding: utf-8 -*-
from abc import ABCMeta, abstractmethod
class abs_min:
class abs_api_min:
__metaclass__ = ABCMeta
@abstractmethod
def isSetup(self):
def is_setup(self):
'''Is setup service (True/False)'''
@abstractmethod
def getPrioritet(self):
def get_prioritet(self):
'''Get prioritet 0-100
users 50-70
'''
@abstractmethod
def getVars(self):
def get_vars(self):
'''Get Service vars
'''
class abs_api(abs_min):
class abs_api_service(abs_api_min):
__metaclass__ = ABCMeta
@abstractmethod
def getServiceName(self):
def get_service_name(self):
'''Get name service'''
@abstractmethod
def isStart(self):
def is_start(self):
'''Is run server (True/False)'''
@abstractmethod
@ -44,33 +44,28 @@ class abs_api(abs_min):
'''Stop server'''
@abstractmethod
def isRunlevel(self):
def is_runlevel(self):
'''Is server in run level (True/False)'''
@abstractmethod
def addRunlevel(self):
def add_runlevel(self):
'''Add daemon to runlevel'''
@abstractmethod
def delRunlevel(self):
def del_runlevel(self):
'''Add daemon to runlevel'''
@abstractmethod
def delVarsFromEnv(self):
def del_vars_from_env(self):
'''Delete template vars in env files
'''
@abstractmethod
def getServiceInfo(self):
'''Get Service information
'''
@abstractmethod
def getPkgName(self):
def get_pkg_name(self):
'''Get package name
'''
@abstractmethod
def applyTemplates(self):
def apply_templates(self):
'''Apply package templates
'''

19
pym/cl_api.py

@ -24,6 +24,7 @@ tr = cl_lang.lang()
tr.setLocalDomain('cl_lib')
tr.setLanguage(sys.modules[__name__])
import cl_overriding
from cl_datavars import DataVars
class APIError(Exception):
@ -57,7 +58,8 @@ class _services(color_print, libVars):
globals(), locals(),
['serviceAPI']),
'serviceAPI')
except (ImportError, AttributeError):
except (ImportError, AttributeError), e:
self.printERROR(str(e).strip())
self.printERROR(_("Can not import module %s")% apiFile)
cl_overriding.exit(1)
return className
@ -75,7 +77,8 @@ class _services(color_print, libVars):
className = self.getApiClass(apiFile)
try:
apiObject = className()
except:
except Exception, e:
self.printERROR(str(e).strip())
self.printERROR(_("Can not create API object"))
self.printERROR(_("Module %s")% apiFile)
cl_overriding.exit(1)
@ -152,13 +155,13 @@ class _pkgAPI(object):
def __init__(self, pkgName):
services = _services()
self.var = False
varObj = services.runMethodToPkg(pkgName, 'getVars')
varObj = services.runMethodToPkg(pkgName, 'get_vars')
if varObj:
self.var = attribute(varObj)
pkgObj = services.getPkgApi(pkgName)
for attr in dir(pkgObj):
if not attr.startswith("_") and callable(getattr(pkgObj, attr)) and\
getattr(pkgObj, attr).im_func.func_code.co_varnames==('self',):
getattr(pkgObj, attr).im_func.func_code.co_argcount == 1:
setattr(self, attr, getattr(pkgObj, attr))
def __getattribute__(self, attr):
@ -180,8 +183,8 @@ class _allPkg(object):
to sort in descending order
'''
prioritetA = objectA.getPrioritet()
prioritetB = objectB.getPrioritet()
prioritetA = objectA.get_prioritet()
prioritetB = objectB.get_prioritet()
if prioritetA == prioritetB:
return 0
elif prioritetA < prioritetB:
@ -194,8 +197,8 @@ class _allPkg(object):
to sort in descending order
'''
prioritetA = objectA.getPrioritet()
prioritetB = objectB.getPrioritet()
prioritetA = objectA.get_prioritet()
prioritetB = objectB.get_prioritet()
if prioritetA == prioritetB:
return 0
elif prioritetA > prioritetB:

4
pym/cl_template.py

@ -4387,8 +4387,8 @@ variable 'cl-name'"))
nameFileTemplate)
preReturn(pathProg)
return ([], False)
self.openFiles(nameFileTemplate, pathOldFile)
if not (flagSymlink and os.path.isdir(pathOldFile)):
self.openFiles(nameFileTemplate, pathOldFile)
if not objHeadNew.params.has_key("chown"):
# Устанавливаем владельцем конфигурационного файла,
# пользователя по умолчанию (переменная шаблона ur_login)

Loading…
Cancel
Save