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))
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)
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()
def poweroff_all(self, *args): if not self.get_all_clients(): return msg=_( _("Do you want to poweroff the following clients: %s?" )%(self.connected_users_txt_all) ) if shared.ask_msg ( msg ): timeout=self.main.config.GetVar("actions_timeout") msg=(_("Pc will shutdown in %s seconds") %timeout) self.exe_app_in_client("poweroff", timeout, msg, users=self.allclients, connected_users=self.connected_users)
def unlock_all(self, *args): if not self.get_all_clients(): return msg=_( _("Do you want to unlock the following screens: %s?" )%(self.connected_users_txt_all) ) if shared.ask_msg ( msg ): self.main.worker=shared.Workers(self.main, None, None) self.main.worker.set_for_all_action(self.action_for_clients, \ self.allclients_logged, "unlockscreen" )
def poweroff(self, w, ip): if not self.get_client(): return msg=_( _("Do you want to poweroff: %s?" ) %(self.connected_users_txt_all) ) if shared.ask_msg ( msg ): timeout=self.main.config.GetVar("actions_timeout") msg=(_("Pc will shutdown in %s seconds") %timeout) self.exe_app_in_client("poweroff", timeout, msg, users=[ip], connected_users=self.connected_users)
def dpms_on_all(self, *args): if not self.get_all_clients(): return msg=_( _("Do you want to switch on the following monitors: %s?" ) %(self.connected_users_txt_all) ) if shared.ask_msg ( msg ): self.main.worker=shared.Workers(self.main, None, None) self.main.worker.set_for_all_action(self.action_for_clients, \ self.allclients_logged, "dpmson" )
def on_kill_button_click(self, widget, pid, username): print_debug ( "on_kill_button_click() pid=%s username=%s" %(pid, username) ) if shared.ask_msg ( _("Are you sure you want to stop this process?") ): print_debug ( "KILL KILL KILL" ) if username.find(":") != -1 : usern, ip = username.split(":") self.main.xmlrpc.newhost(ip) self.main.xmlrpc.DBus("kill", str(pid) ) else: result = self.main.dbus_action.do_kill( [username] , str(pid) ) if not result: shared.error_msg ( _("Error while killing app:\nReason: %s") %( self.main.dbus_action.get_error_msg() ) ) else: print_debug ( "on_kill_button_click() KILLED ;)" ) self.get_user_processes(self.main.selected_ip)
def restartx(self, w, ip): if not self.get_client(): return # restart xorg with new settings # 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)
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 msg=_( _("Do you want to restart X screens (only thin clients):%s?" )%(onlythinclients_txt) ) if shared.ask_msg ( msg ): self.main.worker=shared.Workers(self.main, None, None) self.main.worker.set_for_all_action(self.action_for_clients, onlythinclients, "restartx" )
def locknet_all(self, *args): if not self.get_all_clients(): return if not self.main.localdata.user_in_group(None, 'tcos'): msg=(_("In order to lock and unlock internet you need to be in 'tcos' group.\n\nExe by root: adduser %s tcos" ) %(self.main.localdata.get_username())) shared.error_msg ( msg ) return # disable internet eth=self.main.config.GetVar("network_interface") ports="--ports=%s" %self.main.config.GetVar("ports_tnc") remote_msg=_("Internet connection has been disabled") act="disable-internet" if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG: shared.error_msg( _("No users logged.") ) return msg=_( _("Do you want disable internet to following users: %s?" )%(self.connected_users_txt) ) if not shared.ask_msg ( msg ): return newusernames=[] for user in self.connected_users: if user.find(":") != -1: usern, ip=user.split(":") self.main.xmlrpc.newhost(ip) result = self.main.xmlrpc.tnc(act, usern, ports) if result == "disabled": self.main.xmlrpc.DBus("mess", remote_msg) else: result = self.main.localdata.BlockNet(act, user, ports, eth) if result == "disabled": newusernames.append(user) result = self.main.dbus_action.do_message( newusernames, remote_msg ) for client in self.newallclients: self.main.localdata.newhost(client) self.main.xmlrpc.newhost(client) self.change_lockscreen(client)
def logout(self, w, ip): if not self.get_client(): return if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG: shared.error_msg ( _("User not logged") ) return msg=_( _("Do you want to logout user: %s?" ) %(self.connected_users_txt) ) if shared.ask_msg ( msg ): newusernames=[] timeout=self.main.config.GetVar("actions_timeout") msg=_("Session will close in %s seconds") %timeout remote_cmd="/usr/lib/tcos/session-cmd-send LOGOUT %s %s" %(timeout, msg.replace("'", "´")) if self.connected_users[0].find(":") != -1: # we have a standalone user... self.main.xmlrpc.DBus("exec", remote_cmd ) else: newusernames.append(self.connected_users[0]) self.main.dbus_action.do_exec(newusernames, remote_cmd )
def vnc_demo_all(self, *args): if not self.get_all_clients(): return # demo mode #generate password vnc if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG: shared.error_msg( _("No users logged.") ) return msg=_( _("Do you want to start demo mode the following users: %s?" )%(self.connected_users_txt) ) if not shared.ask_msg ( msg ): return passwd=''.join( Random().sample(string.letters+string.digits, 12) ) self.main.common.exe_cmd("x11vnc -storepasswd %s %s >/dev/null 2>&1" \ %(passwd, os.path.expanduser('~/.tcosvnc')), verbose=0, background=True ) # start x11vnc in local p=subprocess.Popen(["x11vnc", "-shared", "-noshm", "-viewonly", "-forever", "-rfbauth", "%s" %( os.path.expanduser('~/.tcosvnc') ) ], shell=False, bufsize=0, close_fds=True) self.main.write_into_statusbar( _("Waiting for start demo mode...") ) # need to wait for start, PingPort loop status = "CLOSED" max_wait=10 wait=0 while status != "OPEN": status=PingPort("127.0.0.1", 5900).get_status() if status == "CLOSED": sleep(1) wait+=1 if wait > max_wait: break if status != "OPEN": self.main.write_into_statusbar( _("Error while exec app")) return total=0 for client in self.newallclients: self.main.xmlrpc.vnc("genpass", client, passwd ) # get server ip server_ip=self.main.xmlrpc.GetStandalone("get_server") print_debug("menu_event_all() vnc server ip=%s" %(server_ip)) # start vncviewer self.main.xmlrpc.vnc("startclient", client, server_ip ) total+=1 if total < 1: self.main.write_into_statusbar( _("No users logged.") ) # kill x11vnc os.kill(p.pid, signal.SIGKILL) else: self.main.write_into_statusbar( _("Running in demo mode with %s clients.") %(total) ) #server_ip=self.main.xmlrpc.GetStandalone("get_server") #hostname=self.main.localdata.GetHostname(server_ip) # new mode Stop Button if len(self.vnc_count.keys()) != 0: count=len(self.vnc_count.keys())-1 nextkey=self.vnc_count.keys()[count]+1 self.vnc_count[nextkey]=None else: nextkey=1 self.vnc_count[nextkey]=None self.add_progressbox( {"target": "vnc", "ip":"", "pid":p.pid, "allclients":self.newallclients, "key":nextkey}, _("Running in demo mode from server. Demo Nº %s") %(nextkey) )
def vnc_demo_simple(self, widget, ip): if not self.get_client(): return client_simple=self.connected_users_txt if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG: shared.error_msg ( _("Can't start demo mode, user is not logged") ) return msg=_( _("Do you want demo mode from user %s?" ) %(client_simple) ) if not shared.ask_msg ( msg ): return if self.main.iconview.ismultiple(): self.allclients=self.main.iconview.get_multiple() elif self.main.classview.ismultiple(): self.allclients=self.main.classview.get_multiple() elif self.main.listview.isactive() and self.main.config.GetVar("selectedhosts") == 1: self.allclients=self.main.listview.getmultiple() if len(self.allclients) == 0: self.allclients=self.main.localdata.allclients else: # get all clients connected self.allclients=self.main.localdata.allclients # Allow one client # if len(self.allclients) == 0: return # force kill x11vnc in client self.main.xmlrpc.newhost(ip) max_wait=5 wait=0 self.main.write_into_statusbar( _("Connecting with %s to start VNC support") %(client_simple) ) status="OPEN" while status != "CLOSED": status=PingPort(ip, 5900).get_status() self.main.xmlrpc.vnc("stopserver", ip ) print_debug("start_vnc() waiting to kill x11vnc...") sleep(1) wait+=1 if wait > max_wait: print_debug("max_wait, returning") # fixme show error message return #generate password vnc passwd=''.join( Random().sample(string.letters+string.digits, 12) ) self.main.common.exe_cmd("x11vnc -storepasswd %s %s >/dev/null 2>&1" \ %(passwd, os.path.expanduser('~/.tcosvnc')), verbose=0, background=True ) # start x11vnc in remote host self.main.xmlrpc.vnc("genpass", ip, passwd ) self.main.xmlrpc.vnc("startserver", ip ) self.main.write_into_statusbar( _("Waiting for start demo mode from user %s...") %(client_simple) ) # need to wait for start, PingPort loop status = "CLOSED" max_wait=10 wait=0 while status != "OPEN": status=PingPort(ip, 5900).get_status() if status == "CLOSED": sleep(1) wait+=1 if wait > max_wait: break if status != "OPEN": self.main.write_into_statusbar( _("Error while exec app")) return # start in 1 (teacher) newallclients=[] total=1 for client in self.allclients: self.main.localdata.newhost(client) if self.main.localdata.IsLogged(client) and client != ip: self.main.xmlrpc.vnc("genpass", client, passwd ) self.main.xmlrpc.vnc("startclient", client, ip ) total+=1 newallclients.append(client) if total < 1: self.main.write_into_statusbar( _("No users logged.") ) # kill x11vnc in host self.main.xmlrpc.vnc("stopserver", ip ) else: self.main.write_into_statusbar( _("Running in demo mode with %s clients.") %(total) ) #cmd=("LC_ALL=C LC_MESSAGES=C vncviewer --version 2>&1| grep built |grep -c \"4.1\"") #output=self.main.common.exe_cmd(cmd) #if output == "1": # p=subprocess.Popen(["vncviewer", ip, "-UseLocalCursor=0", "-PasswordFile", "%s" %os.path.expanduser('~/.tcosvnc')], shell=False, bufsize=0, close_fds=True) #else: # p=subprocess.Popen(["vncviewer", ip, "-passwd", "%s" %os.path.expanduser('~/.tcosvnc')], shell=False, bufsize=0, close_fds=True) # new mode for stop button if len(self.vnc_count.keys()) != 0: count=len(self.vnc_count.keys())-1 nextkey=self.vnc_count.keys()[count]+1 self.vnc_count[nextkey]=None else: nextkey=1 self.vnc_count[nextkey]=None stopargs={"target": "vnc", "ip": ip, "allclients":newallclients, "key":nextkey} self.vncviewer(ip, passwd, stoptarget=self.on_progressbox_click, stopargs=stopargs) #self.add_progressbox( {"target": "vnc", "pid":p.pid, "ip": ip, "allclients":newallclients, "key":nextkey}, _("Running in demo mode from user %(host)s. Demo Nº %(count)s") %{"host":client_simple, "count":nextkey} ) self.add_progressbox( stopargs, _("Running in demo mode from user %(host)s. Demo Nº %(count)s") %{"host":client_simple, "count":nextkey} )
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()
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()
def rtp_chat(self, *args): if not self.get_all_clients(): return # conference mode if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG: shared.error_msg( _("No users logged.") ) return # cmd=("LC_ALL=C LC_MESSAGES=C pactl --version 2>/dev/null | awk '{print $2}' | awk -F\".\" '{if ((int($2) >= 9) && (int($3) >= 10)) printf 1}'") # output=self.main.common.exe_cmd(cmd) # if output != "1": # shared.error_msg( _("Your pulseaudio server is too old.\nIs required pulseaudio version >= 0.9.10") ) # return msg=_( _("Do you want to start audio chat conference to the following users: %s?" )%(self.connected_users_txt) ) if not shared.ask_msg ( msg ): return remote_msg=_("You have entered in audio chat conference. Participants: %s") %self.connected_users_txt eth=self.main.config.GetVar("network_interface") max_uip=255 uip=0 while uip <= max_uip: uip_cmd="225.0.0.%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" and uip_cmd not in self.rtp_count.values(): print_debug("Broadcast ip found: %s" %(uip_cmd)) ip_broadcast="%s" %uip_cmd break elif uip == max_uip: print_debug("Not found an available broadcast ip") return result = self.main.localdata.Route("route-add", ip_broadcast, "255.255.255.255", eth) if result == "error": print_debug("Add multicast-ip route failed") return self.main.write_into_statusbar( _("Waiting for start audio chat conference...") ) output_send="" output_recv="" self.rtp_control_count[ip_broadcast]=[] self.main.common.exe_cmd("/usr/lib/tcos/pactl-controller.sh start-server") msg=_( "Do you want to connect to this audio chat conference now?" ) if shared.ask_msg ( msg ): output_send = self.main.common.exe_cmd("pactl load-module module-rtp-send format=s16be channels=2 rate=44100 source=@DEFAULT_SOURCE@ loop=0 destination=%s" %ip_broadcast) output_recv = self.main.common.exe_cmd("pactl load-module module-rtp-recv sap_address=%s" %ip_broadcast) self.rtp_control_count[ip_broadcast]=[output_send, output_recv] total=0 for client in self.newallclients: self.main.xmlrpc.rtp("startrtp-chat", client, ip_broadcast ) total+=1 if total < 1: self.main.write_into_statusbar( _("No users logged.") ) # kill x11vnc if output_send != "" or output_recv != "": self.main.common.exe_cmd("pactl unload-module %s" %output_send) self.main.common.exe_cmd("pactl unload-module %s" %output_recv) del self.rtp_control_count[ip_broadcast] result = self.main.localdata.Route("route-del", ip_broadcast, "255.255.255.255", eth) if result == "error": print_debug("Del multicast-ip route failed") if len(self.rtp_count.keys()) == 0: self.main.common.exe_cmd("/usr/lib/tcos/pactl-controller.sh stop-server") else: 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) self.main.xmlrpc.DBus("mess", remote_msg) else: newusernames.append(user) self.main.dbus_action.do_message( newusernames, remote_msg ) self.main.write_into_statusbar( _("Running in audio chat conference with %s clients.") %(total) ) # new mode Stop Button if len(self.rtp_count.keys()) != 0: count=len(self.rtp_count.keys())-1 nextkey=self.rtp_count.keys()[count]+1 self.rtp_count[nextkey]=ip_broadcast else: nextkey=1 self.rtp_count[nextkey]=ip_broadcast if self.control_list: self.populate_data(self.rtp_count) #self.main.menus.broadcast_count[ip_broadcast]=None self.add_progressbox( {"target": "rtp-chat", "pid_send":output_send, "pid_recv":output_recv, "allclients":self.newallclients, "ip":"", "ip_broadcast":ip_broadcast, "iface":eth, "key":nextkey}, _("Running in audio chat conference. Conference Nº %s") %(nextkey) )
def rtp_simple(self, widget, ip_simple): if not self.get_client(): return client_simple=self.connected_users_txt # conference mode if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG: shared.error_msg( _("Can't start conference mode, user is not logged") ) return # cmd=("LC_ALL=C LC_MESSAGES=C pactl --version 2>/dev/null | awk '{print $2}' | awk -F\".\" '{if ((int($2) >= 9) && (int($3) >= 10)) printf 1}'") # output=self.main.common.exe_cmd(cmd) # if output != "1": # shared.error_msg( _("Your pulseaudio server is too old.\nIs required pulseaudio version >= 0.9.10") ) # return msg=_( _("Do you want audio conference from user %s?" ) %(client_simple) ) if not shared.ask_msg ( msg ): return # Allow one client # if len(self.allclients) == 0: return remote_msg=_("You have entered in audio conference from user %s") %client_simple eth=self.main.config.GetVar("network_interface") max_uip=255 uip=0 while uip <= max_uip: uip_cmd="225.0.0.%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" and uip_cmd not in self.rtp_count.values(): print_debug("Broadcast ip found: %s" %(uip_cmd)) ip_broadcast="%s" %uip_cmd break elif uip == max_uip: print_debug("Not found an available broadcast ip") return if not self.get_all_clients(): return result = self.main.localdata.Route("route-add", ip_broadcast, "255.255.255.255", eth) if result == "error": print_debug("Add multicast-ip route failed") return #self.main.xmlrpc.newhost(ip) self.main.xmlrpc.rtp("startrtp-send", ip_simple, ip_broadcast ) self.main.write_into_statusbar( _("Waiting for start audio conference from user %s...") %(client_simple) ) output = self.main.common.exe_cmd("pactl load-module module-rtp-recv sap_address=%s" %ip_broadcast) newallclients2=[] total=1 for client in self.newallclients: self.main.localdata.newhost(client) if client != ip_simple: self.main.xmlrpc.rtp("startrtp-recv", client, ip_broadcast ) total+=1 newallclients2.append(client) if total < 1: self.main.write_into_statusbar( _("No users logged.") ) self.main.common.exe_cmd("pactl unload-module %s" %output) self.main.xmlrpc.rtp("stoprtp-send", ip_simple ) result = self.main.localdata.Route("route-del", ip_broadcast, "255.255.255.255", eth) if result == "error": print_debug("Del multicast-ip route failed") else: 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) self.main.xmlrpc.DBus("mess", remote_msg) else: newusernames.append(user) self.main.dbus_action.do_message( newusernames, remote_msg ) self.main.write_into_statusbar( _("Running in audio conference with %s clients.") %(total) ) # new mode Stop Button if len(self.rtp_count.keys()) != 0: count=len(self.rtp_count.keys())-1 nextkey=self.rtp_count.keys()[count]+1 self.rtp_count[nextkey]=ip_broadcast else: nextkey=1 self.rtp_count[nextkey]=ip_broadcast #self.main.menus.broadcast_count[ip_broadcast]=None self.add_progressbox( {"target": "rtp", "pid":output, "allclients":newallclients2, "ip":ip_simple, "ip_broadcast":ip_broadcast, "iface":eth, "key":nextkey}, _("Running in audio conference from user %(host)s. Conference Nº %(count)s") %{"host":client_simple, "count":nextkey} )