]> git.llucax.com Git - software/pymin.git/blobdiff - pymin/services/proxy/__init__.py
Give a nice error if a VPN key can't be readed (refs #22).
[software/pymin.git] / pymin / services / proxy / __init__.py
index 0577938271deced0545b6786caf08fa8f6545fe4..5ab624beba4737f26ec3efbd664c6b07505aa989 100644 (file)
@@ -1,6 +1,7 @@
 # vim: set encoding=utf-8 et sw=4 sts=4 :
 
 from os import path
+import logging ; log = logging.getLogger('pymin.services.proxy')
 
 from pymin.seqtools import Sequence
 from pymin.dispatcher import Handler, handler, HandlerError
@@ -10,18 +11,7 @@ from pymin.services.util import Restorable, ConfigWriter, InitdHandler, \
 
 import crypt
 
-__ALL__ = ('ProxyHandler', 'Error')
-
-class Error(HandlerError):
-    r"""
-    Error(command) -> Error instance :: Base DnsHandler exception class.
-
-    All exceptions raised by the DnsHandler inherits from this one, so you can
-    easily catch any DnsHandler exception.
-
-    message - A descriptive error message.
-    """
-    pass
+__all__ = ('ProxyHandler',)
 
 class Host(Sequence):
     def __init__(self,ip):
@@ -35,8 +25,8 @@ class HostHandler(DictSubHandler):
 
     handler_help = u"Manage proxy hosts"
 
-    _dict_subhandler_attr = 'hosts'
-    _dict_subhandler_class = Host
+    _cont_subhandler_attr = 'hosts'
+    _cont_subhandler_class = Host
 
 class User(Sequence):
     def __init__(self, name, password):
@@ -52,8 +42,8 @@ class UserHandler(DictSubHandler):
 
     handler_help = u"Manage proxy users"
 
-    _dict_subhandler_attr = 'users'
-    _dict_subhandler_class = User
+    _cont_subhandler_attr = 'users'
+    _cont_subhandler_class = User
 
 class ProxyHandler(Restorable, ConfigWriter, InitdHandler,
                    TransactionalHandler, ParametersHandler):
@@ -78,10 +68,11 @@ class ProxyHandler(Restorable, ConfigWriter, InitdHandler,
 
     def __init__(self, pickle_dir='.', config_dir='.'):
         r"Initialize DhcpHandler object, see class documentation for details."
+        log.debug(u'ProxyHandler(%r, %r)', pickle_dir, config_dir)
         self._persistent_dir = pickle_dir
         self._config_writer_cfg_dir = config_dir
         self._config_build_templates()
-        self._restore()
+        InitdHandler.__init__(self)
         self.host = HostHandler(self)
         self.user = UserHandler(self)
 
@@ -93,6 +84,12 @@ class ProxyHandler(Restorable, ConfigWriter, InitdHandler,
 
 if __name__ == '__main__':
 
+    logging.basicConfig(
+        level   = logging.DEBUG,
+        format  = '%(asctime)s %(levelname)-8s %(message)s',
+        datefmt = '%H:%M:%S',
+    )
+
     px = ProxyHandler()
     px.set('ip','192.66.66.66')
     px.set('port','666')