← Back to team overview

epoptes team mailing list archive

Re: [Question #260336]: Plugins development

 

Question #260336 on Epoptes changed:
https://answers.launchpad.net/epoptes/+question/260336

Xangel posted a new comment:
===================================================================
--- data/client-functions	(revisión: 11929)
+++ data/client-functions	(copia de trabajo)
@@ -225,7 +225,7 @@
 # Parameters:
 # $1 = port.
 get_monitored() {
-    background x11vnc -noshm -24to32 -viewonly -connect_or_exit "$SERVER:$1"
+    background x11vnc -noshm -24to32 -viewonly -connect_or_exit "$1"
 }
 
 # Connect to the server to get assistance.
@@ -233,7 +233,7 @@
 # $1 = port.
 # $2 = grab keyboard and mouse.
 get_assisted() {
-    background x11vnc -noshm -24to32 ${2:+-grabptr -grabkbd} -connect_or_exit "$SERVER:$1"
+    background x11vnc -noshm -24to32 ${2:+-grabptr -grabkbd} -connect_or_exit "$1"
 }
 
 # Deactivate the screensaver, in order for the users to watch a broadcast.
@@ -264,13 +264,13 @@
         sleep 0.$(($(hexdump -e \"%d\" -n 2 /dev/urandom) % 50 + 50))
         if [ "$VNCVIEWER" = "ssvncviewer" ]; then
             exec ssvncviewer -shared -viewonly -passwd /dev/stdin \
-                ${3:+-fullscreen} "$SERVER:$1"
+                ${3:+-fullscreen} "$1"
         elif [ "$VNCVIEWER" = "xvnc4viewer" ]; then
             exec xvnc4viewer -Shared -ViewOnly -passwd /dev/stdin \
-                ${3:+-FullScreen -UseLocalCursor=0 -MenuKey F13} "$SERVER:$1"
+                ${3:+-FullScreen -UseLocalCursor=0 -MenuKey F13} "$1"
         else
             exec vncviewer -shared -viewonly -passwd /dev/stdin \
-                ${3:+-fullscreen} "$SERVER:$1"
+                ${3:+-fullscreen} "$1"
         fi
     } >/dev/null 2>&1 &
     EPOPTES_VNCVIEWER_PID="$!"
@@ -295,8 +295,9 @@
 # $1 = port.
 remote_term() {
     local screen_params
-
+    REM=$1
     if [ "$UID" -eq 0 ]; then
+	REM="$SERVER:${1#*:}"
         screen_params="bash -l"
     else
         screen_params="-l"
@@ -304,7 +305,7 @@
     background sh -c "
 cd
 sleep 1
-TERM=xterm exec socat EXEC:'screen $screen_params',pty,stderr tcp:$SERVER:$1"
+TERM=xterm exec socat EXEC:'screen $screen_params',pty,stderr tcp:$REM"
 }
 
 # Ping is called every few seconds just to make sure the connection is alive.
Index: epoptes/ui/gui.py
===================================================================
--- epoptes/ui/gui.py	(revisión: 11929)
+++ epoptes/ui/gui.py	(copia de trabajo)
@@ -26,6 +26,7 @@
 import pygtk
 pygtk.require('2.0')
 
+
 import gtk
 import gobject
 import os
@@ -258,9 +259,16 @@
                     '-listen', str(self.vncviewerport-5500)])
 
         # And, tell the clients to connect to the server
-        self.execOnSelectedClients([cmd, self.vncviewerport] + list(args))
+        # Adding some workarount to solve the "teacher-non-in-server problem"
+        # getting the ip from current machine and use it in xvnc
+        # 
+        class_ip = self.getClassroomIp()
+        if class_ip == None:
+            class_ip = "server"
 
+        self.execOnSelectedClients([cmd, str(class_ip)+":"+str(self.vncviewerport)] + list(args))
 
+
     def assistUser(self, widget, path=None, view_column=None):
         if config.settings.has_option('GUI', 'grabkbdptr'):
             grab = config.settings.getboolean('GUI', 'grabkbdptr')
@@ -299,6 +307,10 @@
             f.close()
             self.pwd=''.join('\\%o' % ord(c) for c in pwd)
             self.vncserverport = self.findUnusedPort()
+            class_ip = self.getClassroomIp()
+            if class_ip == None:
+                class_ip = "server"
+
             self.vncserver = subprocess.Popen(['x11vnc', '-noshm', '-nopw',
                 '-quiet', '-viewonly', '-shared', '-forever', '-nolookup',
                 '-24to32', '-threads', '-rfbport', str(self.vncserverport),
@@ -305,7 +317,7 @@
                 '-rfbauth', pwdfile])
         self.execOnSelectedClients(['stop_screensaver'],
             mode=EM_SYSTEM_AND_SESSION)
-        self.execOnSelectedClients(["receive_broadcast", self.vncserverport, 
+        self.execOnSelectedClients(["receive_broadcast", str(class_ip)+":"+str(self.vncserverport), 
             self.pwd, fullscreen], mode=EM_SYSTEM_OR_SESSION)
 
 
@@ -358,14 +370,22 @@
             inst = client[C_INSTANCE]
             if inst.type == 'offline':
                 continue
+        # Adding some workarount to solve the "teacher-non-in-server problem"
+        # getting the ip from current machine and use it in xvnc
+        class_ip = self.getClassroomIp()
+        if class_ip == None:
+           class_ip = "server"
 
-            port = self.findUnusedPort()
+        port = self.findUnusedPort()
 
-            subprocess.Popen(['xterm', '-e', 'socat',
-                'tcp-listen:%d,keepalive=1' % port, 'stdio,raw,echo=0'])
-            self.execOnClients(['remote_term', port], [client], mode=em)
 
+        subprocess.Popen(['xterm', '-e', 'socat',
+           'tcp-listen:%d,keepalive=1' % port, 'stdio,raw,echo=0'])
 
+        port = str(class_ip)+":"+str(port)
+        self.execOnClients(['remote_term', port], [client], mode=em)
+
+
     def openUserTerminal(self, widget):
         self.openTerminal(EM_SESSION)
 
@@ -970,10 +990,8 @@
         if len(self.cstore) == 0:
             # print 'No clients'
             return False
-        
         if isinstance(command, list) and len(command) > 0:
             command = '%s %s' %(command[0], ' '.join([pipes.quote(str(x)) for x in command[1:]]))
-                    
         if (clients != [] or handles != []) and warning != '':
             if self.warnDlgPopup(warning) == False:
                 return
@@ -983,14 +1001,19 @@
                 if reply:
                     cmd.addCallback(lambda re, h=handle, p=params: reply(h, re, *p))
                     cmd.addErrback(lambda err: self.printErrors("when executing command %s on client %s: %s" %(command,handle, err)))
-
         for client in clients:
             sent = False
             for em in mode:
                 if em == EM_SESSION_ONLY:
                     handle = client[C_SESSION_HANDLE]
                 elif em == EM_SYSTEM_ONLY:
-                    handle = client[C_INSTANCE].hsystem
+                    try:
+                       handle = client[C_INSTANCE].hsystem
+                       print(handle)
+                    except Exception as e:
+                       print(str(e))
                 else: # em == EM_EXIT_IF_SENT
                     if sent:
                         break
@@ -1031,3 +1054,19 @@
     def printErrors(self, error):
         print '  **Twisted error:', error
         return
+
+    def getClassroomIp(self):
+        '''
+        Adding some workarount to solve the "teacher-non-in-server problem"
+        getting the ip from current machine and use it in xvnc
+        ''' 
+        class_ip = None
+        try:
+            import socket
+            s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+            s.connect(("server",80))
+            class_ip = s.getsockname()[0]
+            s.close()
+        except Exception as e:
+            print(str(e))
+        return class_ip

-- 
You received this question notification because you are a member of
Epoptes Developers, which is an answer contact for Epoptes.