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 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 switch_off(): from twisted.internet import reactor import os.path if os.path.exists('/usr/sbin/ethtool'): try: subprocess.call(['ethtool','-s','eth0','wol','g']) except: pass #this will fail if eth0 does not exist if MyUtils.isLTSP()=='': subprocess.call(['killall','-9','x-session-manager']) else: subprocess.call(['poweroff','-w']) try: server,socket = MyUtils.getLDMinfo() if server!='': subprocess.call(['ssh','-O','exit','-S',socket,server]) except: pass reactor.callLater(1,die)
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
try: reactor.listenTCP(Configs.PORT, AulaSite) reactor.callWhenRunning(MyClass.UpdateLists) except CannotListenError: # If we can't use this port, then exit. print(_ListenMsg % str(Configs.PORT)) sys.exit() else: from ControlAula import StudentLoop logging.getLogger().debug("The user is NOT a teacher") MyStudent = StudentLoop.Obey(REFRESH) reactor.callWhenRunning(MyStudent.listen) reactor.callWhenRunning(MyStudent.startScan) if MyUtils.isLTSP() == '': # Start up the web launch service. launchRoot = StudentLoop.ControlAulaProtocol() # Resource object launchRoot.PageDir = Configs.WWWPAGES launchSite = server.Site(launchRoot) reactor.listenTCP(Configs.PORT, launchSite) #begin application loop: reactor.callWhenRunning(checkActivity) logging.getLogger().debug("Starting controlaula") reactor.run() if exitStatus == 97: logging.getLogger().debug("Restarting controlaula due to network changes") reactor.run() sys.exit(exitStatus)
def die(): if MyUtils.isLTSP()=='': subprocess.Popen(['poweroff','-hp']) else: subprocess.Popen(['poweroff','-fp'])