Skip to content

Commit f2c053d

Browse files
committed
cambios para trabajar mejor con network manager
git-svn-id: file:///opt/svn/colegios/controlaula/trunk@833 c4774de7-f4ed-435d-9225-5986420fcf7b
1 parent 3c02f87 commit f2c053d

14 files changed

+75
-15
lines changed

Backend/.project

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>Backend</name>
3+
<name>ControlAula</name>
44
<comment></comment>
55
<projects>
6-
<project>Sirvecole</project>
76
</projects>
87
<buildSpec>
98
<buildCommand>

Backend/.pydevproject

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
<?eclipse-pydev version="1.0"?>
33

44
<pydev_project>
5-
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
6-
<path>/Backend/src</path>
7-
</pydev_pathproperty>
8-
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.5</pydev_property>
95
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
6+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.5</pydev_property>
107
</pydev_project>

Backend/.settings/org.eclipse.core.resources.prefs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#Tue Mar 16 13:11:00 CET 2010
1+
#Fri May 27 13:25:23 CEST 2011
22
eclipse.preferences.version=1
33
encoding//src/ControlAula/Classroom.py=utf-8
44
encoding//src/ControlAula/Desktop.py=utf-8
55
encoding//src/ControlAula/Host.py=utf-8
6+
encoding//src/ControlAula/Plugins/Actions.py=utf-8
67
encoding//src/ControlAula/Plugins/Broadcast.py=utf-8
78
encoding//src/ControlAula/Plugins/Handler.py=utf-8
89
encoding//src/ControlAula/Plugins/StudentHandler.py=utf-8
@@ -13,4 +14,5 @@ encoding//src/ControlAula/TeacherServer.py=utf-8
1314
encoding//src/ControlAula/User.py=utf-8
1415
encoding//src/ControlAula/Utils/Configs.py=utf-8
1516
encoding//src/ControlAula/Utils/MyUtils.py=utf-8
17+
encoding//src/ControlAula/Utils/NetworkUtils.py=utf-8
1618
encoding//src/monitor.py=utf-8

Backend/src/ControlAula/Plugins/Actions.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ def switch_off():
9090
from twisted.internet import reactor
9191
import os.path
9292
if os.path.exists('/usr/sbin/ethtool'):
93-
subprocess.call(['ethtool','-s','eth0','wol','g'])
93+
try:
94+
subprocess.call(['ethtool','-s','eth0','wol','g'])
95+
except:
96+
pass #this will fail if eth0 does not exist
9497

9598
if MyUtils.isLTSP()=='':
9699
subprocess.call(['killall','-9','x-session-manager'])

Backend/src/controlaula.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from subprocess import call
4+
from time import sleep
5+
import sys
6+
7+
if __name__ == '__main__':
8+
exitSignal=call(["python","/usr/share/controlaula/monitor.py"])
9+
while True:
10+
11+
if exitSignal == 97:
12+
sleep(2.0)
13+
exitSignal=call(["python","/usr/share/controlaula/monitor.py"])
14+
else:
15+
sys.exit(0)

Backend/src/monitor.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
PORT=8900
4444
#Interval to check if the hosts are off or users have logout
4545
REFRESH=5
46+
myIp="None"
47+
48+
exitStatus=0
4649

4750
def SigHandler(signum, frame):
4851
print 'Stopping Monitor'
@@ -61,10 +64,19 @@ def SigHandler(signum, frame):
6164
def checkActivity():
6265

6366
def sendNext():
64-
67+
global myIp
68+
global exitStatus
69+
nuevaIP=NetworkUtils.get_ip_inet_address()
70+
71+
if myIp != "None" and myIp != nuevaIP:
72+
exitStatus=97
73+
reactor.stop()
74+
else:
75+
myIp= nuevaIP
76+
6577
if not MyUtils.isActive():
6678
reactor.stop()
67-
sys.exit()
79+
6880

6981
loop = LoopingCall(sendNext)
7082
loop.start(5)
@@ -205,6 +217,9 @@ def __del__(self):
205217
reactor.callWhenRunning(MyStudent.startScan)
206218

207219
#begin application loop:
208-
reactor.callWhenRunning(checkActivity)
220+
reactor.callWhenRunning(checkActivity)
221+
logging.getLogger().debug("Starting controlaula")
209222
reactor.run()
223+
if exitStatus==97: logging.getLogger().debug("Restarting controlaula due to network changes")
224+
sys.exit(exitStatus)
210225

Backend/src/sirvecole.py

-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def prepareBroadcast():
7777
datefmt='%a, %d %b %Y %H:%M:%S',
7878
filename=LOG_FILENAME)
7979

80-
if os.path.exists('/usr/sbin/ethtool'):
81-
subprocess.call(['ethtool','-s','eth0','wol','g'])
8280
######### Begin the application loop #######
8381

8482
from ControlAula import StudentLoop

controlaula

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22

3-
exec python "/usr/share/controlaula/monitor.py"
3+
exec python "/usr/share/controlaula/controlaula.py"
44

debian/99controlaula

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
if [ -z "$1" ]; then
4+
echo "$0: called with no interface" 1>&2
5+
exit 1;
6+
fi
7+
8+
# Run the right scripts
9+
case "$2" in
10+
up)
11+
su root -c "invoke-rc.d controlaula restart &"
12+
exit 0
13+
;;
14+
*)
15+
echo "$0: called with unknown action \`$2'" 1>&2
16+
exit 0
17+
;;
18+
esac

debian/changelog

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
controlaula (1.6.21-1) unstable; urgency=low
2+
3+
* Modified to improve compatibility with network-manager
4+
5+
-- José L. Redrejo Rodríguez <[email protected]> Fri, 27 May 2011 13:46:09 +0200
6+
17
controlaula (1.6.20-1) unstable; urgency=low
28

39
* Increased security for teacher detection

debian/controlaula.dirs

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
88
usr/share/xul-ext-controlaula
99
etc/dhcp3/dhclient-exit-hooks.d
1010
etc/dhcp/dhclient-exit-hooks.d
11+
etc/NetworkManager/dispatcher.d

debian/controlaula.ifup

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
[ "$IFACE" != "lo" ] || exit 0
44

55
#ensure wol is programmed
6-
/usr/sbin/ethtool -s $IFACE wol g
6+
case $IFACE in
7+
eth*) /usr/sbin/ethtool -s $IFACE wol g ;;
8+
*) echo " no eth in $IFACE" ;;
9+
esac
10+

debian/controlaula.install

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ startcontrolaula.desktop etc/xdg/autostart
66
add-on/* usr/share/xul-ext-controlaula
77
debian/controlaula.dhcp etc/dhcp3/dhclient-exit-hooks.d
88
debian/controlaula.ifup etc/network/if-up.d
9+
debian/99controlaula etc/NetworkManager/dispatcher.d

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
datafiles.append(('/etc/xdg/autostart',['startcontrolaula.desktop']))
1818
datafiles.append(('share/controlaula',['nobody.png']))
1919
datafiles.append(('share/controlaula',['Backend/src/monitor.py']))
20+
datafiles.append(('share/controlaula',['Backend/src/controlaula.py']))
2021

2122
setup(name='ControlAula',
2223
version='1.6',

0 commit comments

Comments
 (0)