Revisión 97
Añadido por Manu Mora Gordillo hace alrededor de 14 años
controlies/Utils/avahiClient.py | ||
---|---|---|
|
||
from twisted.internet import defer, threads
|
||
from twisted.internet import glib2reactor
|
||
import logging
|
||
glib2reactor.install()
|
||
|
||
class avahiClient():
|
||
... | ... | |
cb(self,name, address, port)
|
||
|
||
def resolve_service_error(exception):
|
||
self.warning('could not resolve daap service %s %s: %s' % (name, domain, exception))
|
||
logging.getLogger().debug('could not resolve daap service %s %s: %s' % (name, domain, exception))
|
||
#self.warning('could not resolve daap service %s %s: %s' % (name, domain, exception))
|
||
|
||
self.server.ResolveService(interface, protocol, name, type, domain,
|
||
avahi.PROTO_UNSPEC, dbus.UInt32(0),
|
controlies/Plugins/LdapConnection.py | ||
---|---|---|
result_set.append(result_data)
|
||
return result_set
|
||
except ldap.LDAPError, e:
|
||
print e
|
||
logging.getLogger().debug('LDAP error search')
|
||
|
||
"""result = con.search_s( base_dn, ldap.SCOPE_SUBTREE, filter, attrs )
|
||
return result"""
|
||
... | ... | |
self.connection.add_s(baseDN+",dc=instituto,dc=extremadura,dc=es", attr)
|
||
|
||
except ldap.ALREADY_EXISTS:
|
||
print "already exists"
|
||
logging.getLogger().debug("LDAP already exists %s" % (baseDN))
|
||
except ldap.OPERATIONS_ERROR:
|
||
print "error"
|
||
logging.getLogger().debug("LDAP operation error %s" % (baseDN))
|
||
except ldap.NO_SUCH_OBJECT:
|
||
print "no_such_object"
|
||
logging.getLogger().debug("LDAP no such object %s" % (baseDN))
|
||
|
||
return True
|
||
|
controlies/www/classroomServers/index.html | ||
---|---|---|
$('#selectable #selectable-'+computer[1]+' #userName').html(computer[0]);
|
||
$('#selectable #selectable-'+computer[1]+' .thumb-image').attr('src','img/nobody.png');
|
||
});
|
||
|
||
//getLTSPClients();
|
||
|
||
setTimeout("getLTSPStatus()",10000);
|
||
});
|
||
}
|
||
|
||
function getLTSPClients(){
|
||
$.post('hosts','action=getLTSPClients', function(data) {
|
||
var result = $.parseJSON(data);
|
||
|
||
setTimeout("getLTSPClients()",25000);
|
||
});
|
||
}
|
||
|
||
</script>
|
||
|
controlies/MainLoop.py | ||
---|---|---|
|
||
f = open('/tmp/controlIES.ltpsTeachers', 'r')
|
||
teachers = f.read().split(" ")
|
||
teachers.sort()
|
||
teachers.sort()
|
||
|
||
return json.dumps({ "computers":computers, "teachers":teachers })
|
||
|
||
elif request.args['action'][0] == "getLTSPClients":
|
||
|
||
import xmlrpclib
|
||
|
||
h = Hosts (l,"","","","","")
|
||
response = h.getLTSPServers ()
|
||
|
||
clients = []
|
||
for server in response:
|
||
s = xmlrpclib.Server("http://"+server+":8900")
|
||
print "connect: "+server
|
||
try:
|
||
clients[server] = s.Hosts()
|
||
except:
|
||
pass
|
||
|
||
return json.dumps({ "clients":clients })
|
||
|
||
else:
|
||
if request.args ['type'][0] == 'thinclient':
|
||
ip = ""
|
controlies/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