Beispiel #1
0
    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}                
Beispiel #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)
Beispiel #3
0
 def getTreeHome(self):
     path=MyUtils.getHomeUser()
     user=MyUtils.getLoginName()
     r=['<ul class="jqueryFileTree" style="display: none;">']
     r.append('<li class="directory collapsed"><a href="#" rel="%s/">%s</a></li>' % (path,user))
     r.append('<li class="directory collapsed"><a href="#" rel="/media/">Media</a></li>' )        
     r.append('</ul>')
     
     return  ''.join(r)        
 def _handle_chat(self, request):
                
     request.content.read() 
     if request.path=='/student/':                    
         if len(request.args)>0:
             requestedfile=os.path.join(self.PageDir,'chat.html')
             try:
                 page_to_send =open(requestedfile, "r").read()
                 html_to_send=page_to_send.replace('%(student_id)', request.args['login'][0])
                 return html_to_send 
             except:
                 request.setResponseCode(404)
                 return"""
                 <html><head><title>404 - No Such Resource</title></head>
                 <body><h1>No Such Resource</h1>
                 <p>File not found: %s - No such file.</p></body></html>
                 """ % requestedfile     
     else: #chatting
         user_host=request.client.host             
         user = request.args.get('user', user_host)
         key=user[0] + '@' + user_host
         try:
             if MyUtils.getLoginName() + '@127.0.0.1'!=key: 
                 if self.teacher.classroom.LoggedUsers[key].chat_enabled==False:return self.response_ok()
         except:
             return self.response_ok()
                        
         message = request.args.get('message', None)
         
         if not message:
             return self.response_fail(['*message* not found', ])
         message = cgi.escape(message[0])
         response = self.response_ok(user= [  '('+strftime('%H:%M:%S') + ') '+ user[0]], message=message)
         chat_logger = logging.getLogger('Chat')
         chat_logger.info(user[0] + ": " + message )            
         for chann_request in self.channels['controlaula-chat']:
             chann_request.write(response)
             chann_request.finish()
         del self.channels['controlaula-chat']
         return self.response_ok()         
Beispiel #5
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
Beispiel #6
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
Beispiel #7
0
 def getLogin(self):
     return {'login':MyUtils.getLoginName() }