/usr/share/pyshared/ControlAula/TeacherServer.py is in ltsp-controlaula 1.8.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | ##############################################################################
# -*- coding: utf-8 -*-
# Project: Controlaula
# Module: TeacherServer.py
# Purpose: XML-RPC server for the teacher to communicate with the students
# Language: Python 2.5
# Date: 21-Jan-2010.
# Ver: 27-Jan-2010.
# Author: José L. Redrejo Rodríguez
# Copyright: 2009-2010 - José L. Redrejo Rodríguez <jredrejo @nospam@ debian.org>
#
# ControlAula is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# ControlAula is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with ControlAula. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from twisted.web import xmlrpc
from ControlAula.Utils import NetworkUtils,Configs
import os,time
import pynotify
class RPCServer(xmlrpc.XMLRPC):
"""Object used to communicate students pcs with teacher pc
"""
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')
def xmlrpc_getCommands(self, login,hostip):
"""Return the list of commands to be executed by the client"""
if login=='root':
key=hostip
else:
key =login+'@'+hostip
commands=self.classroom.getCommands(key)
return commands
def xmlrpc_connData(self):
return self.classroom.myVNC.getData() + (self.classroom.broadcast.getData(),)
def xmlrpc_screenshot(self,login,hostip, sfile):
key =login+'@'+hostip
if not self.classroom.LoggedUsers.has_key(key):
return "ok"
datum = sfile.data
shotname=login + time.strftime('%Y%m%d%H%M%S',time.localtime()) + '.png'
try:
os.remove(os.path.join(Configs.IMAGES_DIR + '/screenshots',self.classroom.LoggedUsers[key].shotname))
except:
pass
self.classroom.LoggedUsers[key].shotname=shotname
thefacename=os.path.join(Configs.IMAGES_DIR + '/screenshots',shotname)
try:
theface = open(thefacename, "wb")
theface.write(datum)
theface.close()
except:
pass
#os.spawnl(os.P_NOWAIT, '/usr/bin/display', '/tmp/gnu.jpg')
return "ok"
def xmlrpc_facepng(self,login,hostip, sfile):
key =login+'@'+hostip
datum = sfile.data
thefacename=os.path.join(Configs.IMAGES_DIR,login + '.png')
try:
theface = open(thefacename, "wb")
theface.write(datum)
theface.close()
self.classroom.addPhoto('/loginimages/' + login + '.png',key)
except:
pass
return "ok"
def xmlrpc_file(self,login, sfile,filename):
datum = sfile.data
received_dir=os.path.join(Configs.FILES_DIR,self.classroom.classname,login)
if not os.path.exists(received_dir):
os.makedirs(received_dir)
received_file=os.path.join(received_dir,filename)
try:
thefile = open(received_file, "wb")
thefile.write(datum)
thefile.close()
note=login + " ha enviado el fichero "
note +="<a href='file:///" + received_file + "'>" + filename +"</a>"
n=pynotify.Notification("Fichero recibido",note,"dialog-information")
n.set_timeout(pynotify.EXPIRES_DEFAULT)
n.show()
except:
pass
return "ok"
def xmlrpc_getAnswer(self,login,hostip,answer):
key =login+'@'+hostip
deferred_request=self.classroom.LoggedUsers[key].deferred_request
if deferred_request is not None:
deferred_request.write(answer)
deferred_request.finish()
self.classroom.LoggedUsers[key].deferred_request=None
return ""
|