Revisión 97
Añadido por Manu Mora Gordillo hace alrededor de 14 años
Server.py | ||
---|---|---|
##############################################################################
|
||
|
||
from Utils.avahiClient import avahiClient
|
||
|
||
from Utils import Configs
|
||
from twisted.web import static, server
|
||
from twisted.web.server import Session
|
||
from twisted.python.components import registerAdapter
|
||
import logging,logging.handlers
|
||
import MainLoop
|
||
from zope.interface import Interface, Attribute, implements
|
||
from Plugins.LdapConnection import LdapConnection, ILdapConnection
|
||
import os.path
|
||
|
||
# Logging
|
||
log_handler = logging.handlers.RotatingFileHandler(Configs.LOG_FILENAME, maxBytes=100000, backupCount=5)
|
||
log_formatter = logging.Formatter(fmt='%(asctime)s %(levelname)-8s %(message)s',datefmt='%a, %d %b %Y %H:%M:%S')
|
||
log_handler.setFormatter(log_formatter)
|
||
root_logger=logging.getLogger()
|
||
root_logger.addHandler(log_handler)
|
||
root_logger.level=logging.DEBUG
|
||
|
||
|
||
registerAdapter(LdapConnection, Session, ILdapConnection)
|
||
|
||
# Start up the web service.
|
||
Root = MainLoop.ControlIESProtocol() #Resource object
|
||
#Root.PageDir='/home/manu/proyectos/controlies/www/'
|
||
Root.PageDir='/home/chisco/Proyectos/controlies/www'
|
||
Root.PageDir='/home/manu/proyectos/controlies/www/'
|
||
#Root.PageDir='/home/chisco/Proyectos/controlies/www'
|
||
site = server.Site(Root)
|
||
|
||
fileNameServers = '/tmp/controlIES.ltpsSevers'
|
||
... | ... | |
_monitor.add_callback('new-service', _add_locationServers)
|
||
_monitor.add_callback('remove-service', _remove_locationServers)
|
||
_monitor.start()
|
||
|
||
except Exception, ex:
|
||
error_msg = "Couldn't initialize Avahi monitor: %s" % str(ex)
|
||
#raise InitializeFailure(self.name, error_msg)
|
||
logging.getLogger().debug("Couldn't initialize Avahi monitor: workstations")
|
||
|
||
|
||
try:
|
||
_monitor = avahiClient('_controlaula._tcp')
|
||
_monitor.add_callback('new-service', _add_locationTeachers)
|
||
_monitor.add_callback('remove-service', _remove_locationTeachers)
|
||
_monitor.start()
|
||
|
||
_monitor.start()
|
||
except Exception, ex:
|
||
error_msg = "Couldn't initialize Avahi monitor: %s" % str(ex)
|
||
#raise InitializeFailure(self.name, error_msg)
|
||
logging.getLogger().debug("Couldn't initialize Avahi monitor: controlaula")
|
||
|
||
|
||
from twisted.internet import reactor
|
Exportar a: Unified diff
Añadiendo logging