X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/55efba31a241826ed31597b14f2b5eb9efe808f1..fac20bd5c930ab027e9c097f34bf50714f8a53d5:/pymin/services/util.py?ds=inline diff --git a/pymin/services/util.py b/pymin/services/util.py index 69864cf..00f2385 100644 --- a/pymin/services/util.py +++ b/pymin/services/util.py @@ -17,7 +17,7 @@ from pymin.seqtools import Sequence #DEBUG = False DEBUG = True -__ALL__ = ('Error', 'ExecutionError', 'ItemError', 'ItemAlreadyExistsError', +__all__ = ('Error', 'ExecutionError', 'ItemError', 'ItemAlreadyExistsError', 'ItemNotFoundError', 'ContainerError', 'ContainerNotFoundError', 'call', 'get_network_devices', 'Persistent', 'Restorable', 'ConfigWriter', 'ServiceHandler', 'RestartHandler', @@ -101,7 +101,7 @@ class ItemAlreadyExistsError(ItemError): def __init__(self, key): r"Initialize the object. See class documentation for more info." - self.message = u'Item already exists: "%s"' % key + self.message = u'Item already exists: %s' % key class ItemNotFoundError(ItemError): r""" @@ -362,7 +362,7 @@ class Restorable(Persistent): return False class ConfigWriter: - r"""ConfigWriter([initd_name[, initd_dir]]) -> ConfigWriter. + r"""ConfigWriter([files[, cfg_dir[, tpl_dir]]]) -> ConfigWriter. This is a helper class to inherit from to automatically handle configuration generation. Mako template system is used for configuration @@ -850,7 +850,9 @@ class ContainerSubHandler(SubHandler): # do we have the same item? then raise an error if key in self._vattr(): log.debug(u'ContainerSubHandler.add: allready exists') - raise ItemAlreadyExistsError(item) + if not isinstance(self._attr(), dict): + key = self._attr().index(item) + raise ItemAlreadyExistsError(key) # do we have the same item, but logically deleted? then update flags if key in self._attr(): log.debug(u'ContainerSubHandler.add: was deleted, undeleting it') @@ -916,7 +918,7 @@ class ContainerSubHandler(SubHandler): log.debug(u'ContainerSubHandler.clear()') # FIXME broken really, no _delete attribute is setted :S if isinstance(self._attr(), dict): - self._attr.clear() + self._attr().clear() else: self._attr(list()) @@ -1049,7 +1051,9 @@ class ComposedSubHandler(SubHandler): # do we have the same item? then raise an error if key in self._vattr(cont): log.debug(u'ComposedSubHandler.add: allready exists') - raise ItemAlreadyExistsError(item) + if not isinstance(self._attr(), dict): + key = self._attr().index(item) + raise ItemAlreadyExistsError(key) # do we have the same item, but logically deleted? then update flags if key in self._attr(cont): log.debug(u'ComposedSubHandler.add: was deleted, undeleting it')