コード例 #1
0
ファイル: wakeonlan.py プロジェクト: mariodebian/tcosmonitor
 def wol_all(self, *args):
     if self.main.config.GetVar("scan_network_method") != "static":
         msg=(_("Wake On Lan only works with static list.\n\nEnable scan method \"static\" in Preferences\nand (wake on lan) support in bios of clients." ))
         shared.info_msg ( msg )
         return
                 
     msg=_( _("Do you want boot all clients?" ))
     if shared.ask_msg ( msg ):
         data=[]
         hostslist=self.main.config.GetVar("statichosts")
         #eth=self.main.config.GetVar("network_interface")
         if hostslist == "":
             return
         data=hostslist.split("#")
         data=data[:-1]
         errors=[]
         for host in data:
             mac=host.split("|")[1]
             if mac == "":
                 self.main.write_into_statusbar(_("No register MAC address for ip: \"%s\"")%host)
                 continue
             print_debug("Send magic packet to mac=%s" %mac)
             if not WakeOnLan("%s"%mac):
                 errors.append(mac)
         if len(errors) >1:
             print_debug("menu_event_all() errors=%s"%errors)
             self.main.write_into_statusbar(_("Not valid MAC address: \"%s\"")%" ".join(errors))
コード例 #2
0
ファイル: wakeonlan.py プロジェクト: mariodebian/tcosmonitor
 def wol_one(self, widget, ip):
     if not self.get_client():
         print_debug("wol_one() no client")
         return
     if self.main.config.GetVar("scan_network_method") != "static":
         msg=(_("Wake On Lan only works with static list.\n\nEnable scan method \"static\" in Preferences\nand (wake on lan) support in bios of clients." ))
         shared.info_msg ( msg )
         return
                 
     msg=_( _("Do you want boot %s client?" %ip))
     if shared.ask_msg ( msg ):
         data=[]
         hostslist=self.main.config.GetVar("statichosts")
         #eth=self.main.config.GetVar("network_interface")
         if hostslist == "":
             return
         data=hostslist.split("#")
         data=data[:-1]
         for host in data:
             mip, mac=host.split("|")
             print_debug("wol_one() ip=%s mac=%s" %(mip, mac) )
             if mip == self.main.selected_ip:
                 if mac == "":
                     self.main.write_into_statusbar(_("No register MAC address for ip: \"%s\"")%ip)
                     continue
                 print_debug("Send magic packet to mac=%s" %mac)
                 if not WakeOnLan("%s"%mac):
                     self.main.write_into_statusbar(_("Not valid MAC address: \"%s\"")%mac)
コード例 #3
0
 def on_buttondelete_click(self, widget):
     print_debug("on_buttondelete_click()")
     # ask for delete
     if shared.ask_msg(_("Really delete config of %s?") % (shared.remotehost)):
         print_debug("on_buttondelete_click() deleting file")
         os.remove(self.remotehost_config)
     shared.info_msg(_("Deleted!"))
     self.quitapp()
コード例 #4
0
ファイル: sendfiles.py プロジェクト: mariodebian/tcosmonitor
 def send_external(self, filenames):
     if self.main.classview.ismultiple():
         if not self.get_all_clients():
             return
     elif not self.get_client():
         return
     # action sent by vidal_joshur at gva dot es
     # send files
     # search for connected users
     if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG:
         shared.error_msg ( _("Can't send files, user is not logged") )
         return
     
     if not os.path.isdir("/tmp/tcos_share"):
         shared.info_msg( _("TcosMonitor: FTP+TLS server is not running.") )
         return
     
     for filename in os.listdir("/tmp/tcos_share/"):
         if os.path.isfile("/tmp/tcos_share/%s" %filename):
             os.remove("/tmp/tcos_share/%s" %filename)
             
     open="True"                                
     basenames = ""
     for filename in filenames:
         basenames += "%s\n" % ( os.path.basename(filename[7:]) )
         copy(filename[7:], "/tmp/tcos_share/")
         os.chmod("/tmp/tcos_share/%s" %os.path.basename(filename[7:]), 0644)
     self.main.write_into_statusbar( _("Waiting for send files...") )
                         
     newusernames=[]
         
     for user in self.connected_users:
         if user.find(":") != -1:
             usern, ip=user.split(":")
             self.main.xmlrpc.newhost(ip)
             server=self.main.xmlrpc.GetStandalone("get_server")
             self.main.xmlrpc.DBus("sendfiles", "%s %s %s" %(_("Teacher"), server, open) )
             self.main.xmlrpc.DBus("mess", _("Teacher has sent some files to %(teacher)s folder:\n\n%(basenames)s")  %{"teacher":_("Teacher"), "basenames":basenames})
         else:
             newusernames.append(user)
             
     interface=self.main.config.GetVar("network_interface")
     # maybe we the x remote display is other than tcosmonitor server
     server=self.get_ip_address(interface)
     result = self.main.dbus_action.do_sendfiles( newusernames , _("Teacher"), server, open)
         
     if not result:
         shared.error_msg ( _("Error while exec remote app:\nReason:%s") %( self.main.dbus_action.get_error_msg() ) )
         self.main.write_into_statusbar( _("Error creating destination folder.") )
     else:
         result = self.main.dbus_action.do_message(newusernames ,
                     _("Teacher has sent some files to %(teacher)s folder:\n\n%(basenames)s") %{"teacher":_("Teacher"), "basenames":basenames} )
         
     self.main.write_into_statusbar( _("Files sent.") )
コード例 #5
0
 def launch_tcospersonalize(self, w, ip):
     if not self.get_client():
         return
     if self.client_type == "tcos":
         if self.main.ingroup_tcos == False and os.getuid() != 0:
             cmd="gksu \"tcospersonalize --host=%s\"" %(ip)
         else:
             cmd="tcospersonalize --host=%s" %(ip)
         print_debug ( "launch_tcospersonalize() cmd=%s" %(cmd) )
         th=self.main.common.exe_cmd( cmd, verbose=0, background=True )
     else:
         shared.info_msg( _("%s is not supported to personalize!") %(self.client_type) )
コード例 #6
0
    def on_buttongetavalaible_click(self, widget):
        print_debug("on_button_getavalaible_click()")
        import tcosmonitor.TcosXauth

        self.xauth = tcosmonitor.TcosXauth.TcosXauth(self)
        import tcosmonitor.TcosConf

        self.config = tcosmonitor.TcosConf.TcosConf(self)
        import tcosmonitor.TcosXmlRpc

        self.xmlrpc = tcosmonitor.TcosXmlRpc.TcosXmlRpc(self)
        self.xmlrpc.newhost(shared.remotehost)
        if not self.xmlrpc.connected:
            shared.error_msg(_("Host down, can't connect to tcosxmlrpc."))
            print_debug("on_buttongetavalaible_click() host down!!")
            return
        # alldrivers=self.xmlrpc.GetDevicesInfo("", "--getxdrivers").split('|')[0:-1]
        alldrivers = self.xmlrpc.GetDevicesInfo("", "--getxdrivers")
        print_debug("on_buttongetavalaible_click() alldrivers=%s" % (alldrivers))
        alldrivers = alldrivers.split("|")[0:-1]
        self.populate_select(self.combo_xdriver, shared.xdriver_values + alldrivers, set_text_column=False)
        shared.info_msg(_("New %d drivers loaded from terminal.") % (len(alldrivers)))
コード例 #7
0
ファイル: videolan.py プロジェクト: mariodebian/tcosmonitor
    def video_external(self, filename):
        if self.main.classview.ismultiple():
            if not self.get_all_clients():
                return
        elif not self.get_client():
            return
        # action sent by vidal_joshur at gva dot es
        # start video broadcast mode
        # Stream to single client unicast
        eth=self.main.config.GetVar("network_interface")
        
        if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG:
            shared.error_msg ( _("Can't send video broadcast, user is not logged") )
            return
                    
        str_scapes=[" ", "(", ")", "*", "!", "?", "\"", "`", "[", "]", "{", "}", ";", ":", ",", "=", "$"]
        lock="disable"
        volume="85"
        
        if self.main.pref_vlc_method_send.get_active() == 0:
            vcodec=shared.vcodecs[0]
            venc=shared.vencs[0]
            acodec=shared.acodecs[0]
            aenc=shared.aencs[0]
            access=shared.accesss[0]
            mux=shared.muxs[0]
        elif self.main.pref_vlc_method_send.get_active() == 1:
            vcodec=shared.vcodecs[1]
            venc=shared.vencs[0]
            acodec=shared.acodecs[0]
            aenc=shared.aencs[0]
            access=shared.accesss[0]
            mux=shared.muxs[0]
        elif self.main.pref_vlc_method_send.get_active() == 2:
            vcodec=shared.vcodecs[2]
            venc=shared.vencs[1]
            acodec=shared.acodecs[0]
            aenc=shared.aencs[0]
            access=shared.accesss[0]
            mux=shared.muxs[0]
        elif self.main.pref_vlc_method_send.get_active() == 3:
            vcodec=shared.vcodecs[3]
            venc=shared.vencs[2]
            acodec=shared.acodecs[1]
            aenc=shared.aencs[1]
            access=shared.accesss[1]
            mux=shared.muxs[1]
        elif self.main.pref_vlc_method_send.get_active() == 4:
            vcodec=shared.vcodecs[1]
            venc=shared.vencs[0]
            acodec=shared.acodecs[1]
            aenc=shared.aencs[1]
            access=shared.accesss[1]
            mux=shared.muxs[1]
        
        if access == "udp":
            max_uip=255
            uip=0
            while uip <= max_uip:
                uip_cmd="239.254.%s.0" %(uip)
                cmd=("LC_ALL=C LC_MESSAGES=C netstat -putan 2>/dev/null | grep -c %s" %(uip_cmd) )
                print_debug("Check broadcast ip %s." %(uip_cmd) )
                output=self.main.common.exe_cmd(cmd)
                uip+=1
                if output == "0":
                    print_debug("Broadcast ip found: %s" %(uip_cmd))
                    ip_broadcast="%s:1234" %uip_cmd
                    break
                elif uip == max_uip:
                    print_debug("Not found an available broadcast ip")
                    return
        else:
            max_uip=50255
            uip=50000
            while uip <= max_uip:
                uip_cmd=":%s" %(uip)
                cmd=("LC_ALL=C LC_MESSAGES=C netstat -putan 2>/dev/null | grep -c %s" %(uip_cmd) )
                print_debug("Check broadcast ip %s." %(uip_cmd) )
                output=self.main.common.exe_cmd(cmd)
                uip+=1
                if output == "0":
                    print_debug("Broadcast ip found: %s" %(uip_cmd))
                    ip_broadcast=uip_cmd
                    uip_cmd=""
                    break
                elif uip == max_uip:
                    print_debug("Not found an available broadcast ip")
                    return

        if uip_cmd != "":
            result = self.main.localdata.Route("route-add", uip_cmd, "255.255.255.0", eth)
            if result == "error":
                print_debug("Add multicast-ip route failed")
                return
                
        if filename.find(" ") != -1:
            msg=_("Not allowed white spaces in \"%s\".\nPlease rename it." %os.path.basename(filename) )
            shared.info_msg( msg )
            return
            
        if access == "udp":
            remote_cmd_standalone="vlc udp://@%s --udp-caching=1000 --aout=alsa --brightness=2.000000 --volume=300 --fullscreen --aspect-ratio=4:3 --loop" %(ip_broadcast)
            remote_cmd_thin="vlc udp://@%s --udp-caching=1000 --aout=alsa --brightness=2.000000 --volume=300 --aspect-ratio=4:3 --loop" %(ip_broadcast)
            
        p=subprocess.Popen(["vlc", "file://%s" %filename, "--sout=#duplicate{dst=display{delay=1000},dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=800,ab=112,channels=2,soverlay}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_broadcast), "--miface=%s" %eth, "--ttl=12", "--brightness=2.000000"], shell=False, bufsize=0, close_fds=True)
            
        self.main.write_into_statusbar( _("Waiting for start video transmission...") )
            
        #msg=_("First select the DVD chapter or play movie\nthen press enter to send client..." )
        #shared.info_msg( msg )
            
        # check if vlc is running or fail like check ping in demo mode
        running = p.poll() is None
        if not running:
            self.main.write_into_statusbar( _("Error while exec app"))
            return
            
        #msg=_( "Lock keyboard and mouse on client?" )
        #if shared.ask_msg ( msg ):
        #    lock="enable"
                
        newusernames=[]
            
        for user in self.connected_users:
            if user.find(":") != -1:
                # we have a standalone user...
                usern, ip = user.split(":")
                self.main.xmlrpc.newhost(ip)
                if access == "http":
                    server=self.main.xmlrpc.GetStandalone("get_server")
                    remote_cmd_standalone="vlc http://%s%s --aout=alsa --brightness=2.000000 --volume=300 --fullscreen --aspect-ratio=4:3 --http-reconnect --loop" %(server, ip_broadcast)
                self.main.xmlrpc.DBus("exec", remote_cmd_standalone )
            else:
                newusernames.append(user)
                        
        if access == "http":
            remote_cmd_thin="vlc http://localhost%s --aout=alsa --brightness=2.000000 --volume=300 --aspect-ratio=4:3 --http-reconnect --loop" % (ip_broadcast)
                    
        result = self.main.dbus_action.do_exec( newusernames, remote_cmd_thin )
            
        if not result:
            shared.error_msg ( _("Error while exec remote app:\nReason:%s") %( self.main.dbus_action.get_error_msg() ) )
            
        for client in self.newallclients:
            self.main.xmlrpc.vlc( client, volume, lock )
            
        self.main.write_into_statusbar( _("Running in broadcast video transmission.") )
        # new mode to Stop Button
        if len(self.vlc_count.keys()) != 0:
            count=len(self.vlc_count.keys())-1
            nextkey=self.vlc_count.keys()[count]+1
            self.vlc_count[nextkey]=uip_cmd
        else:
            nextkey=1
            self.vlc_count[nextkey]=uip_cmd
        self.add_progressbox( {"target": "vlc", "pid":p.pid, "lock":lock, "allclients":self.newallclients, "ip":uip_cmd, "iface":eth, "key":nextkey}, _("Running in broadcast video transmission to user %(host)s. Broadcast Nº %(count)s") %{"host":self.connected_users_txt, "count":nextkey} )
コード例 #8
0
ファイル: videolan.py プロジェクト: mariodebian/tcosmonitor
    def video_all(self, *args):
        if not self.get_all_clients():
            return
        # action sent by vidal_joshur at gva dot es
        # start video broadcast mode
        # search for connected users
        # Stream to multiple clients
        eth=self.main.config.GetVar("network_interface")
        
        if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG:
            shared.error_msg( _("No users logged.") )
            return
                    
        str_scapes=[" ", "(", ")", "*", "!", "?", "\"", "`", "[", "]", "{", "}", ";", ":", ",", "=", "$"]
        
        if self.main.pref_vlc_method_send.get_active() == 0:
            vcodec=shared.vcodecs[0]
            venc=shared.vencs[0]
            acodec=shared.acodecs[0]
            aenc=shared.aencs[0]
            access=shared.accesss[0]
            mux=shared.muxs[0]
        elif self.main.pref_vlc_method_send.get_active() == 1:
            vcodec=shared.vcodecs[1]
            venc=shared.vencs[0]
            acodec=shared.acodecs[0]
            aenc=shared.aencs[0]
            access=shared.accesss[0]
            mux=shared.muxs[0]
        elif self.main.pref_vlc_method_send.get_active() == 2:
            vcodec=shared.vcodecs[2]
            venc=shared.vencs[1]
            acodec=shared.acodecs[0]
            aenc=shared.aencs[0]
            access=shared.accesss[0]
            mux=shared.muxs[0]
        elif self.main.pref_vlc_method_send.get_active() == 3:
            vcodec=shared.vcodecs[3]
            venc=shared.vencs[2]
            acodec=shared.acodecs[1]
            aenc=shared.aencs[1]
            access=shared.accesss[1]
            mux=shared.muxs[1]
        elif self.main.pref_vlc_method_send.get_active() == 4:
            vcodec=shared.vcodecs[1]
            venc=shared.vencs[0]
            acodec=shared.acodecs[1]
            aenc=shared.aencs[1]
            access=shared.accesss[1]
            mux=shared.muxs[1]
        
        if access == "udp":
            max_uip=255
            uip=0
            while uip <= max_uip:
                uip_cmd="239.254.%s.0" %(uip)
                cmd=("LC_ALL=C LC_MESSAGES=C netstat -putan 2>/dev/null | grep -c %s" %(uip_cmd) )
                print_debug("Check broadcast ip %s." %(uip_cmd) )
                output=self.main.common.exe_cmd(cmd)
                uip+=1
                if output == "0":
                    print_debug("Broadcast ip found: %s" %(uip_cmd))
                    ip_broadcast="%s:1234" %uip_cmd
                    break
                elif uip == max_uip:
                    print_debug("Not found an available broadcast ip")
                    return
        else:
            max_uip=50255
            uip=50000
            while uip <= max_uip:
                uip_cmd=":%s" %(uip)
                cmd=("LC_ALL=C LC_MESSAGES=C netstat -putan 2>/dev/null | grep -c %s" %(uip_cmd) )
                print_debug("Check broadcast ip %s." %(uip_cmd) )
                output=self.main.common.exe_cmd(cmd)
                uip+=1
                if output == "0":
                    print_debug("Broadcast ip found: %s" %(uip_cmd))
                    ip_broadcast=uip_cmd
                    uip_cmd=""
                    break
                elif uip == max_uip:
                    print_debug("Not found an available broadcast ip")
                    return
        
        lock="disable"
        volume="85"

        if uip_cmd != "":
            result = self.main.localdata.Route("route-add", uip_cmd, "255.255.255.0", eth)
            if result == "error":
                print_debug("Add multicast-ip route failed")
                return

        dialog = gtk.FileChooserDialog(_("Select audio/video file.."),
                           None,
                           gtk.FILE_CHOOSER_ACTION_OPEN,
                           (_("Play DVD"), 1,
                            _("Play SVCD/VCD"), 2,
                            _("Play AudioCD"), 3,
                            gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                            gtk.STOCK_OPEN, gtk.RESPONSE_OK))
        dialog.set_default_response(gtk.RESPONSE_OK)
        self.folder = self._folder = os.environ['HOME']
        dialog.set_current_folder(self.folder)
        filter = gtk.FileFilter()
        filter.set_name("Media Files ( *.avi, *.mpg, *.mpeg, *.mp3, *.wav, etc.. )")
        file_types=["*.avi", "*.mpg", "*.mpeg", "*.ogg", "*.ogm", "*.asf", "*.divx", 
                    "*.wmv", "*.vob", "*.m2v", "*.m4v", "*.mp2", "*.mp4", "*.ac3", 
                    "*.ogg", "*.mp1", "*.mp2", "*.mp3", "*.wav", "*.wma"]
        for elem in file_types:
            filter.add_pattern( elem )
        
        dialog.add_filter(filter)
        
        filter = gtk.FileFilter()
        filter.set_name("All Files")
        filter.add_pattern("*.*")
        dialog.add_filter(filter)

        response = dialog.run()
        if response == gtk.RESPONSE_OK or response == 1 or response == 2 or response == 3:
            
            filename=dialog.get_filename()
            dialog.destroy()
                
            #for scape in str_scapes:
            #    filename=filename.replace("%s" %scape, "\%s" %scape)
            
            if response == gtk.RESPONSE_OK:
                if filename.find(" ") != -1:
                    msg=_("Not allowed white spaces in \"%s\".\nPlease rename it." %os.path.basename(filename) )
                    shared.info_msg( msg )
                    return
                p=subprocess.Popen(["vlc", "file://%s" %filename, "--sout=#duplicate{dst=display{delay=1000},dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=800,ab=112,channels=2,soverlay}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_broadcast), "--miface=%s" %eth, "--ttl=12", "--brightness=2.000000"], shell=False, bufsize=0, close_fds=True)
            elif response == 1:
                p=subprocess.Popen(["vlc", "dvdsimple:///dev/cdrom", "--sout=#duplicate{dst=display{delay=700},dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=800,ab=112,channels=2,soverlay}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_broadcast), "--miface=%s" %eth, "--ttl=12", "--loop", "--brightness=2.000000"], shell=False, bufsize=0, close_fds=True)
            elif response == 2:
                p=subprocess.Popen(["vlc", "vcd:///dev/cdrom", "--sout=#duplicate{dst=display{delay=1000},dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=800,ab=112,channels=2,soverlay}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_broadcast), "--miface=%s" %eth, "--ttl=12", "--brightness=2.000000"], shell=False, bufsize=0, close_fds=True)
            elif response == 3:
                p=subprocess.Popen(["vlc", "cdda:///dev/cdrom", "--sout=#duplicate{dst=display,dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=200,ab=112,channels=2}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_broadcast), "--miface=%s" %eth, "--ttl=12"], shell=False, bufsize=0, close_fds=True)
            # exec this app on client
            
            if access == "udp":
                remote_cmd_standalone="vlc udp://@%s --udp-caching=1000 --aout=alsa --brightness=2.000000 --volume=300 --fullscreen --aspect-ratio=4:3 --loop" %(ip_broadcast)
                remote_cmd_thin="vlc udp://@%s --udp-caching=1000 --aout=alsa --brightness=2.000000 --volume=300 --aspect-ratio=4:3 --loop" %(ip_broadcast)

            self.main.write_into_statusbar( _("Waiting for start video transmission...") )
        
            msg=_("First select the DVD chapter or play movie\nthen press enter to send clients..." )
            shared.info_msg( msg )
            
            # check if vlc is running or fail like check ping in demo mode
            running = p.poll() is None
            if not running:
                self.main.write_into_statusbar( _("Error while exec app"))
                return
            
            msg=_( "Lock keyboard and mouse on clients?" )
            if shared.ask_msg ( msg ):
                lock="enable"
                
            newusernames=[]
            
            for user in self.connected_users:
                if user.find(":") != -1:
                    # we have a standalone user...
                    usern, ip = user.split(":")
                    self.main.xmlrpc.newhost(ip)
                    if access == "http":
                        server=self.main.xmlrpc.GetStandalone("get_server")
                        remote_cmd_standalone="vlc http://%s%s --aout=alsa --brightness=2.000000 --volume=300 --fullscreen --aspect-ratio=4:3 --http-reconnect --loop" %(server, ip_broadcast)
                    self.main.xmlrpc.DBus("exec", remote_cmd_standalone )
                else:
                    newusernames.append(user)
                        
            if access == "http":
                remote_cmd_thin="vlc http://localhost%s --aout=alsa --brightness=2.000000 --volume=300 --aspect-ratio=4:3 --http-reconnect --loop" % (ip_broadcast)
                    
            result = self.main.dbus_action.do_exec( newusernames, remote_cmd_thin )
            
            if not result:
                shared.error_msg ( _("Error while exec remote app:\nReason:%s") %( self.main.dbus_action.get_error_msg() ) )
            
            for client in self.newallclients:
                self.main.xmlrpc.vlc( client, volume, lock )
                
            self.main.write_into_statusbar( _("Running in broadcast video transmission.") )
            # new mode Stop Button
            if len(self.vlc_count.keys()) != 0:
                count=len(self.vlc_count.keys())-1
                nextkey=self.vlc_count.keys()[count]+1
                self.vlc_count[nextkey]=uip_cmd
            else:
                nextkey=1
                self.vlc_count[nextkey]=uip_cmd
            self.add_progressbox( {"target": "vlc", "pid":p.pid, "lock":lock, "allclients": self.newallclients, "ip":uip_cmd, "iface":eth, "key":nextkey}, _("Running in broadcast video transmission. Broadcast Nº %s") %(nextkey) )
        else:
            dialog.destroy()
コード例 #9
0
ファイル: viewproc.py プロジェクト: mariodebian/tcosmonitor
 def get_user_processes(self, ip):
     """get user processes in session"""
     print_debug( "get_user_processes(%s) __init__" %ip )
     #check user is connected
     if not self.main.localdata.IsLogged(ip):
         shared.info_msg( _("User not connected, no processes.") )
         return
     
     
     if self.main.xmlrpc.IsStandalone(ip):
         username=self.main.localdata.GetUsernameAndHost(ip)
         tmp=self.main.xmlrpc.ReadInfo("get_process")
         if tmp != "":
             process=tmp.split('|')[0:-1]
         else:
             process=["PID COMMAND", "66000 can't read process list"]
     else:    
         username=self.main.localdata.GetUsername(ip)
         cmd="LANG=C ps U \"%s\" -o pid,command | /usr/lib/tcos/clean_string.sh " %(self.main.localdata.GetUserID(username))
         print_debug ( "get_user_processes(%s) cmd=%s " %(ip, cmd) )
         process=self.main.common.exe_cmd(cmd, verbose=0)
     
     self.main.datatxt.clean()
     self.main.datatxt.insert_block(   _("Running processes for user \"%s\": " ) %(username), image=shared.IMG_DIR + "info_proc.png"  )
     
     if self.main.config.GetVar("systemprocess") == "0":
         self.main.datatxt.insert_block ( \
         _("ALERT: There are some system process hidden. Enable it in Preferences dialog.") \
         , image=shared.IMG_DIR + "icon_alert.png" ,\
         color="#f08196", size="medium" )
     
     self.main.datatxt.insert_html ( """
     <br/><div style='margin-left: 135px; margin-right: 200px;background-color:#ead196;color:blue'>""" + _("Pid") + "\t" 
     + "\t" + _("Process command") +"</div>" )
     
     counter=0
     self.main.kill_proc_buttons=None
     self.main.kill_proc_buttons=[]
     blabel=_("Kill this process")
     
     for proc in process:
         is_hidden=False
         if proc.split()[0]== "PID":
             continue
         pid=proc.split()[0] # not convert to int DBUS need string
         name=" ".join(proc.split()[1:])
         name=name.replace('<','&lt;').replace('>','&gt;')
         name=name.replace('&','&amp;')
         
         if int(self.main.config.GetVar("systemprocess")) == 0:
             for hidden in shared.system_process:
                 # print_debug ( "%s in %s"  % (hidden, name))
                 if hidden in name:
                     is_hidden=True
         
         if is_hidden:
             continue
         
         kill_button=gtk.Button(label=blabel)
         kill_button.connect("clicked", self.on_kill_button_click, pid, username)
         kill_button.show()
         self.main.kill_proc_buttons.append(kill_button)
                 
         self.main.datatxt.insert_html("""
         <span style='background-color: red; margin-left: 5px; margin-right: 0px'>
         <input type='button' name='self.main.kill_proc_buttons' index='%d' label='%s' /></span>
         <span style='color: red; margin-left: 140px; margin-right: 0px'> %6s</span>
         <span style='color: blue; margin-left: 350px; margin-right: 0px'> %s</span><br />
         """ %(counter, blabel, pid, name) )
         counter+=1
     
     self.main.datatxt.display()
     return
コード例 #10
0
        # thin client must download again XXX.XXX.XXX.XXX.conf and rebuild xorg.conf
        if self.client_type == "tcos":
            msg=_( "Restart X session of %s with new config?" ) %(self.host)
            if shared.ask_msg ( msg ):
                # see xmlrpc/xorg.h, rebuild will download and sed xorg.conf.tpl
                try:
                    self.main.xmlrpc.tc.tcos.xorg("rebuild", "--restartxorg", \
                        self.main.config.GetVar("xmlrpc_username"), \
                        self.main.config.GetVar("xmlrpc_password")  )
                except Exception, err:
                    print_debug("restartx() Exception error %s"%err)
                    self.main.xmlrpc.CheckSSL(err)
                
                self.refresh_client_info(ip)
        else:
            shared.info_msg( _("%s is not supported to restart Xorg!") %(self.client_type) )

    def restartx_all(self, widget):
        if not self.get_all_clients():
            return
        onlythinclients=[]
        onlythinclients_txt=""
        
        for client in self.allclients:
            if not self.main.xmlrpc.IsStandalone(client):
                onlythinclients.append(client)
                onlythinclients_txt+="\n %s" %(client)
                
        if len(onlythinclients) == 0:
            shared.error_msg( _("No thin clients found.") )
            return
コード例 #11
0
ファイル: sendfiles.py プロジェクト: mariodebian/tcosmonitor
 def send_all(self, *args):
     if not self.get_all_clients():
         return
     # action sent by vidal_joshur at gva dot es
     # send files
     # search for connected users
     if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG:
         shared.error_msg( _("No users logged.") )
         return
     
     str_scapes=[" ", "(", ")", "*", "!", "?", "\"", "`", "[", "]", "{", "}", ";", ":", ",", "=", "$"]
     
     dialog = gtk.FileChooserDialog( _("Select file or files..."),
                        None,
                        gtk.FILE_CHOOSER_ACTION_OPEN,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                         gtk.STOCK_OPEN, gtk.RESPONSE_OK))
     dialog.set_default_response(gtk.RESPONSE_OK)
     #dialog.set_select_multiple(select_multiple)
     dialog.set_select_multiple(True)
     self.folder = self._folder = os.environ['HOME']
     dialog.set_current_folder(self.folder)
     filter = gtk.FileFilter()
     filter.set_name("All files")
     filter.add_pattern("*")
     dialog.add_filter(filter)
     
     
     if not os.path.isdir("/tmp/tcos_share"):
         shared.info_msg( _("TcosMonitor: FTP+TLS server is not running.") )
         return
     
     for filename in os.listdir("/tmp/tcos_share/"):
         if os.path.isfile("/tmp/tcos_share/%s" %filename):
             os.remove("/tmp/tcos_share/%s" %filename)
                 
     response = dialog.run()
     
     if response == gtk.RESPONSE_OK:
         
         filenames = dialog.get_filenames()
         
         open="False"
         basenames = ""
         for filename in filenames:
             basenames += "%s\n" % ( os.path.basename(filename) )
             copy(filename, "/tmp/tcos_share/")
             os.chmod("/tmp/tcos_share/%s" %os.path.basename(filename), 0644)
         self.main.write_into_statusbar( _("Waiting for send files...") )
         
         msg=_( "Do you want open file(s) on client?" )
         if shared.ask_msg ( msg ):
             open="True"
         
         newusernames=[]
         
         for user in self.connected_users:
             if user.find(":") != -1:
                 usern, ip=user.split(":")
                 self.main.xmlrpc.newhost(ip)
                 server=self.main.xmlrpc.GetStandalone("get_server")
                 self.main.xmlrpc.DBus("sendfiles", "%s %s %s" %(_("Teacher"), server, open) )
                 self.main.xmlrpc.DBus("mess", _("Teacher has sent some files to %(teacher)s folder:\n\n%(basenames)s")  %{"teacher":_("Teacher"), "basenames":basenames})
             else:
                 newusernames.append(user)
                     
         interface=self.main.config.GetVar("network_interface")
         # maybe we the x remote display is other than tcosmonitor server
         server=self.get_ip_address(interface)
         result = self.main.dbus_action.do_sendfiles( newusernames , _("Teacher"), server, open)
         
         if not result:
             shared.error_msg ( _("Error while exec remote app:\nReason:%s") %( self.main.dbus_action.get_error_msg() ) )
             self.main.write_into_statusbar( _("Error creating destination folder.") )
         else:
             result = self.main.dbus_action.do_message(newusernames ,
                         _("Teacher has sent some files to %(teacher)s folder:\n\n%(basenames)s") %{"teacher":_("Teacher"), "basenames":basenames} )
         
         self.main.write_into_statusbar( _("Files sent.") )
     dialog.destroy()