Exemple #1
0
def prepareBroadcast():        
    NetworkUtils.cleanRoutes()
    ltspGW=NetworkUtils.ltspGW()
    if ltspGW!='0':
        NetworkUtils.addRoute('239.255.255.0', ltspGW)
    else:
        reactor.callLater(10, prepareBroadcast)
Exemple #2
0
 def receive(self,encodec=False,teacherIP=''):        
     self.destroyProcess(self.procRx) 
     my_login = MyUtils.getLoginName()
     isLTSP = (MyUtils.isLTSP()!='')
     if my_login == 'root': NetworkUtils.cleanRoutes()              
     command = 'vlc -I dummy ' 
     if isLTSP:
         command +=  ' --no-overlay --vout=xcb_x11 '
     command +=  '--quiet --video-on-top --skip-frames --sout-display-delay=1100  --sub-track=0 --no-overlay '
     
     command +='  -f  rtp://@239.255.255.0:'
     command += self.port 
     logged=MyUtils.logged_user()
     if not isLTSP and my_login != 'root':
         self.procRx=subprocess.Popen(command, stdout=subprocess.PIPE,shell=True)
         MyUtils.launchAs("xset s off",my_login)
     else:    
         if logged !='root':
             self.procRx=MyUtils.launchAs(command, logged)
             MyUtils.launchAs("xset s off",logged)                
         else:        
             self.procRx=MyUtils.launchAsNobody(command)
               
     MyUtils.dpms_on()        
     Actions.disableKeyboardAndMouse(False)
    def requestRegister(self, uid):
        """The client sends the registration data to the server
        and start pings as a keepalive detection"""
        self.uuid = uid
        self.my_server = self.transport.getPeer()
        self.mylogin = MyUtils.getLoginName()
        self.hostip = NetworkUtils.get_ip_inet_address(self.transport.getPeer().host)
        is_host_not_user = (self.mylogin=='root')
        isLTSP = MyUtils.isLTSP()

        info_host = {'login' : self.mylogin,
                   'hostname' : NetworkUtils.getHostName(),
                   'hostip' : self.hostip,
                   'ltsp' : isLTSP != '',
                   'classname' : Configs.RootConfigs['classroomname'],
                   'isHostnotUser' : is_host_not_user ,
                   'uuid' : self.uuid
                   }                 

        if is_host_not_user :
            info_host['mac'] = NetworkUtils.get_inet_HwAddr(self.transport.getPeer().host)
        else:
            info_host['username'] = MyUtils.getFullUserName()
            info_host['ipLTSP'] = isLTSP
            info_host['internetEnabled'] = Configs.MonitorConfigs.GetGeneralConfig('internet') == '1'
            info_host['mouseEnabled'] = Configs.MonitorConfigs.GetGeneralConfig('mouse') == '1'
            info_host['soundEnabled'] = Configs.MonitorConfigs.GetGeneralConfig('sound') == '1'
            info_host['messagesEnabled'] = Configs.MonitorConfigs.GetGeneralConfig('messages') == '1'
            info_host['photo'] = ''
            
        self.doPing()            
        return {'result': info_host}                
 def __init__(self):
     xmlrpc.XMLRPC.__init__(self)
     self.classroom=None
     self.externalIP=NetworkUtils.get_ip_inet_address()
     if self.externalIP=='':
         self.externalIP=NetworkUtils.get_ip_inet_address('192.168.0.254')
     self.hostname=NetworkUtils.getHostName()
     pynotify.init('controlaula')
Exemple #5
0
    def sendNext():
        if not work:
            loop.stop()
            d.callback(None)
            return defer.succeed(None)
        next = work.pop(0)

        #subprocess.Popen(['wakeonlan',next ])
        #subprocess.Popen(['wakeonlan','-i','192.168.0.255',next ])
        NetworkUtils.startup(next)
                   
        return None
Exemple #6
0
    def sendNext():
        global myIp
        global exitStatus
        nuevaIP = NetworkUtils.get_ip_inet_address()

        if myIp != "None" and myIp != nuevaIP:
            exitStatus = 97
            reactor.stop()
        else:
            myIp = nuevaIP

        if not MyUtils.isActive():
            reactor.stop()
Exemple #7
0
 def addHost(self, host):
     """Add a pc to the classroom"""
     if not self.Hosts.has_key(host.ip):
         logging.getLogger().debug("The  host  %s has appeared" % (host.ip))
         self.Hosts[host.ip] = host
         # intialize list of commands for this client, if is a LTSP server, it needs to be added
         if not self.CommandStack.has_key(host.ip):
             self.CommandStack[host.ip] = []
         # save its mac address:
         Configs.MonitorConfigs.SaveMAC(host.hostname, host.mac)
         if host.hostname != NetworkUtils.getHostName():  # the teacher host is not added to the list when it's LTSP
             self.placeHostDesktop(host.ip)
     self.getJSONFrontend("refresh")
Exemple #8
0
 def __init__(self,bcastport=0):
     '''
     Parameters:
     bcastport=The port use in the video broadcasting
     '''          
     if bcastport==0:
         self.port=str(7000+os.getuid())
     else:
         self.port=bcastport
        
     self.procTx=None
     self.procRx=None
     self.handler=None
     self._callbacks = {'started':[],  'ended':[]}
     self.url=''
     self.dvd=False
     self.broadcasting=False
     self.myIP=NetworkUtils.get_ip_inet_address()
     self.codec_h264=self.is_h264_available()
Exemple #9
0
    def broadcast(self, url='', isDVD=False):
        from os.path import isfile
        if url=='DVD':
            isDVD=True
            url=''
        if not isDVD:
            if not isfile(url):
                return {'result':'Bad file'} 

        for i in NetworkUtils.all_interfaces():
            if i[0]!='lo':
                try:
                    self.classroom.CommandStack[i[1]].append(['rootClean','239.255.255.0',NetworkUtils.ltspGW()])
                except: #host not avaialble
                    pass              
        self.classroom.broadcast.clean_callbacks() 
        self.classroom.broadcast.add_callback('started',self.startbcast)
        self.classroom.broadcast.add_callback('ended',self.stopbcast)
        result=self.classroom.broadcast.transmit(url,isDVD)
        if result!=True:
            self.stopbcast
            return {'result':result} 
Exemple #10
0
 def __init__(self,readonly=True,readpasswd='',writepasswd='',clientport=5400):
     '''
     Parameters:
     readonly=True if the server won't allow keyboard and mouse control
     readpasswd= passwd to use when not controlling keyboard and mouse
     writepasswd= passwd to use when controlling keyboard and mouse
     clientport=the port the client has to use to connect to a VNC server
     '''
     if readpasswd=='':
         self.readPasswd=MyUtils.generateUUID()
     else:
         self.readPasswd=readpasswd
         
     if writepasswd=='':
         self.writePasswd=MyUtils.generateUUID()
     else:
         self.writePasswd=writepasswd
         
     self.isLTSP=MyUtils.isLTSP()
         
     if self.isLTSP=='':
         self.port=str(NetworkUtils.getUsableTCPPort('127.0.0.1',5400))
     else:
         d=self.isLTSP.split('.')
         if len(d)<4: #sometimes, it needs two tries :(
             d=self.isLTSP.split('.')
         self.port=str(5400 + int(d[3]))
         
     self.readonly=readonly
     
     self.procServer=None
     self.clientport=clientport
     self.myteacher=None
     self.mylogin=MyUtils.getLoginName()
     self.myIP=''
     self.activeBB=False
Exemple #11
0
    NetworkUtils.cleanRoutes()
    ltspGW=NetworkUtils.ltspGW()
    if ltspGW!='0':
        NetworkUtils.addRoute('239.255.255.0', ltspGW)
    else:
        reactor.callLater(10, prepareBroadcast)
        
 
from twisted.internet import reactor



# Initialise the signal handler.
signal.signal(signal.SIGINT, SigHandler)  

HOSTNAME=NetworkUtils.getHostName()



logging.basicConfig(level=logging.DEBUG,
                format='%(asctime)s %(levelname)-8s %(message)s',
                datefmt='%a, %d %b %Y %H:%M:%S',
                filename=LOG_FILENAME)

######### Begin the application loop #######

from ControlAula import StudentLoop

#vlc cache for the nobody user:
if not os.path.isdir('/nonexistent'):
    try:
Exemple #12
0
    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

    # Initialise the signal handler.
    signal.signal(signal.SIGINT, SigHandler)

    #Get and save some global variables:
    isTeacher = MyUtils.userIsTeacher()

    #isTeacher=False  #enable for debugging
    USERNAME = MyUtils.getLoginName()
    HOSTNAME = NetworkUtils.getHostName()
    Configs.PORT = NetworkUtils.getUsableTCPPort("localhost", PORT)
    MyUtils.putLauncher('', Configs.PORT, isTeacher)

    if not isTeacher:
        from twisted.internet import glib2reactor
        glib2reactor.install()
    from twisted.internet import reactor
    from twisted.web import server
    
    ######### Begin the application loop #######
    if  isTeacher:
        logging.getLogger().debug("The user is a teacher")
        from ControlAula import TeacherMainLoop, Classroom
        from ControlAula.Utils  import Publications