from pymin.dispatcher import Handler, handler, HandlerError
-#DEBUG = False
-DEBUG = True
+DEBUG = False
+#DEBUG = True
__ALL__ = ('ServiceHandler', 'InitdHandler', 'Persistent', 'ConfigWriter',
'Error', 'ReturnNot0Error', 'ExecutionError', 'call')
message - A descriptive error message.
"""
-
- def __init__(self, message):
- r"Initialize the object. See class documentation for more info."
- self.message = message
-
- def __str__(self):
- return self.message
+ pass
class ReturnNot0Error(Error):
r"""
r"Initialize the object. See class documentation for more info."
self.return_value = return_value
- def __str__(self):
+ def __unicode__(self):
return 'The command returned %d' % self.return_value
class ExecutionError(Error):
self.command = command
self.error = error
- def __str__(self):
+ def __unicode__(self):
command = self.command
if not isinstance(self.command, basestring):
command = ' '.join(command)
r"_restore() -> bool :: Restore persistent data or create a default."
try:
self._load()
+ # TODO tener en cuenta servicios que hay que levantar y los que no
+ if hasattr(self, 'commit'): # TODO deberia ser reload y/o algo para comandos
+ self.commit()
return True
except IOError:
for (k, v) in self._restorable_defaults.items():
setattr(self, k, v)
+ # TODO tener en cuenta servicios que hay que levantar y los que no
+ if hasattr(self, 'commit'):
+ self.commit()
+ return False
self._dump()
if hasattr(self, '_write_config'):
self._write_config()
+ if hasattr(self, 'reload'):
+ self.reload()
return False
class ConfigWriter:
self._dump()
if hasattr(self, '_write_config'):
self._write_config()
- if hasattr(self, '_reload'):
+ if hasattr(self, 'reload'):
self.reload()
@handler(u'Discard all the uncommited changes.')