def exe_app_in_client(self, mode, timeout=0, msg="", users=[], connected_users=[]): remote_cmd=("/usr/lib/tcos/session-cmd-send %s %s %s" %(mode.upper(), timeout, msg.replace("'", "´"))) action="down-controller %s %s" %(mode, timeout) print_debug("exe_app_in_client() usernames=%s" %users) if len(connected_users) != 0 and connected_users[0] != shared.NO_LOGIN_MSG: newusernames=[] for user in connected_users: if user.find(":") != -1: # we have a standalone user... usern, ip = user.split(":") self.main.xmlrpc.newhost(ip) self.main.xmlrpc.DBus("exec", remote_cmd ) else: # we have a thin client newusernames.append(user) result = self.main.dbus_action.do_exec( newusernames, remote_cmd ) if not result: shared.error_msg ( _("Error while exec remote app:\nReason:%s") %( self.main.dbus_action.get_error_msg() ) ) self.main.worker=shared.Workers(self.main, None, None) self.main.worker.set_for_all_action(self.action_for_clients, users, action ) return
def locknet_simple(self, w, ip): if not self.get_client(): return # lock net 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 ( _("Can't disable internet, user is not logged") ) return if self.client_type == "tcos": 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 result = self.main.localdata.BlockNet(act, self.connected_users[0], ports, eth) if result == "disabled": self.main.dbus_action.do_message( self.connected_users, remote_msg ) else: result = self.main.xmlrpc.tnc(act, self.connected_users[0].split(":")[0], ports) if result == "disabled": self.main.xmlrpc.DBus("mess", remote_msg) self.change_lockscreen(ip)
def send_msg(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 ( _("Can't send message, user is not logged") ) return self.askfor(mode="mess", users=self.connected_users, users_txt=self.connected_users_txt)
def exe_app_external(self, filename=None, txt=None): if self.main.classview.ismultiple() or txt != None: if not self.get_all_clients(): return elif not self.get_client(): return if len(self.connected_users) == 0 or self.connected_users[0] == shared.NO_LOGIN_MSG: shared.error_msg ( _("Can't exec application, user is not logged") ) return #print_debug("user=%s data=%s" %(self.connected_users, data) app="" self.ask_usernames=self.connected_users self.ask_mode="exec" if txt != None: app="x-www-browser %s" %txt self.exe_app_in_client_display(app) return print_debug("open_file() reading data from \"%s\"..." \ %(filename) ) try: fd=file(filename, 'r') data=fd.readlines() fd.close() except Exception, err: shared.error_msg( _("%s is not a valid application") %(os.path.basename(filename)) ) return
def viewproc(self, widget, 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 ( _("Can't show runnings apps, user is not logged") ) return self.get_user_processes(ip)
def save_screenshot(self, image, number, pixbuf): data=self.__screenshot_data[number] dialog = gtk.FileChooserDialog(title=_("Select file to save screenshot..."), action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK)) dialog.set_default_response(gtk.RESPONSE_OK) dialog.set_current_name( _("screenshot_of_%(hostname)s_date_%(date)s.png") %{'hostname':data['hostname'], 'date':data['date']} ) folder = _folder = os.environ['HOME'] dialog.set_current_folder(folder) _filter = gtk.FileFilter() _filter.set_name( _("Image Files ( *.png, *.jpg)") ) file_types=["*.png", "*.jpg"] for elem in file_types: _filter.add_pattern( elem ) dialog.add_filter(_filter) response = dialog.run() if response == gtk.RESPONSE_OK: filename=dialog.get_filename() fext=filename.split('.')[-1] if not fext in ['png', 'jpg']: shared.error_msg( _("File must be png or jpg.") ) dialog.destroy() return params={} # if fext == "jpeg": # {"quality":"100"} pixbuf.save(filename, fext, params) dialog.destroy()
def unlock(self, w, ip): if not self.get_client(): return if not self.main.xmlrpc.unlockscreen(): shared.error_msg( _("Can't connect to tcosxmlrpc.\nPlease verify user and password in prefences!") ) return self.change_lockscreen(ip)
def on_volumemanager_button_click(self, widget, ip): print_debug ( "on_volumemanager_button_click() ip=%s" %(ip) ) cmd="PULSE_SERVER=\"%s\" paman" %(ip) if os.path.isdir("/dev/shm"): self.main.common.exe_cmd( cmd, verbose=0, background=True ) else: shared.error_msg ( _("PulseAudio apps need /dev/shm.") )
def exe_app(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 ( _("Can't exec application, user is not logged") ) return self.askfor(mode="exec", users=self.connected_users, users_txt=self.connected_users_txt)
def InitStatusIcon(self): if hasattr(gtk, 'status_icon_new_from_file'): # use gtk.status_icon self.statusIcon = gtk.status_icon_new_from_file(tcosmonitor.shared.IMG_DIR + "tcos-devices-32x32.png") self.statusIcon.set_tooltip( _("Tcos Devices") ) self.statusIcon.connect('popup-menu', self.popup_menu) else: shared.error_msg( _("ERROR: No tray icon support") ) sys.exit(1)
def vnc_simple(self, w, ip): if not self.get_client(): return if len(self.allclients_logged) == 0: shared.error_msg( _("No user logged.") ) return self.main.worker=shared.Workers(self.main, target=self.start_vnc, args=(self.allclients_logged) ) self.main.worker.start()
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.") )
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 exe_app_in_client_display(self, arg): usernames=self.ask_usernames newusernames=[] print_debug("exe_app_in_client_display() usernames=%s" %usernames) if arg.startswith('rm ') or arg.find(" rm ") != -1 \ or arg.startswith('mv ') or arg.find(" mv ") != -1 \ or arg.startswith('cp ') or arg.find(" cp ") != -1: arg="" #if self.ask_mode == "mess": # arg=arg.replace("'", "´") if self.ask_mode == "exec": if arg.startswith('http://') or arg.startswith('https://') or arg.startswith('ftp://'): arg="xdg-open %s" %arg for user in usernames: if user.find(":") != -1: # we have a standalone user... usern, ip = user.split(":") print_debug("exe_app_in_client_display() STANDALONE username=%s ip=%s" %(usern, ip)) self.main.xmlrpc.newhost(ip) self.main.xmlrpc.DBus(self.ask_mode, arg) else: newusernames.append(user) # we have a thin client user if self.ask_mode == "exec": result = self.main.dbus_action.do_exec( newusernames , arg ) if not result: shared.error_msg ( _("Error while exec remote app:\nReason: %s") %( self.main.dbus_action.get_error_msg() ) ) else: self.main.ask.hide() self.main.ask_entry.set_text("") elif self.ask_mode == "mess": result = self.main.dbus_action.do_message( newusernames , arg) if not result: shared.error_msg ( _("Error while send message:\nReason: %s") %( self.main.dbus_action.get_error_msg() ) ) self.main.ask_dragdrop.hide() self.main.ask_fixed.hide() self.main.image_entry.hide() self.main.ask.hide() self.main.ask_entry.set_text("") dbus_action=None self.ask_mode=None return
def SaveToFile(self): self.issaved = True print_debug("SaveToFile() len(self.vars)=%d" % (len(self.vars))) if len(self.vars) < 1: print_debug("SaveToFile() self.vars is empty") return try: fd = file(self.remotehost_config, "w") except IOError: shared.error_msg("Can't write into %s file.\n\nRun as root?" % (self.remotehost_config)) return for i in range(len(self.vars)): fd.write("%s=%s\n" % (self.vars[i][0], self.vars[i][1])) fd.close() print_debug("SaveToFile() new settings SAVED!!!") return
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 start_ivs(self, ip): self.main.xmlrpc.newhost(ip) # check if remote proc is running if not self.main.xmlrpc.GetStatus("ivs"): self.main.common.threads_enter("TcosActions:start_ivs write connecting msg") self.main.write_into_statusbar( "Connecting with %s to start iTALC support" %(ip) ) self.main.common.threads_leave("TcosActions:start_ivs write connecting msg") try: self.main.xmlrpc.newhost(ip) self.main.xmlrpc.Exe("startivs") self.main.common.threads_enter("TcosActions:start_ivs write waiting msg") self.main.write_into_statusbar( "Waiting for start of IVS server..." ) self.main.common.threads_leave("TcosActions:start_ivs write waiting msg") sleep(5) except Exception, err: print_debug("start_ivs() Exception, error=%s"%err) self.main.common.threads_enter("TcosActions:start_ivs write error msg") shared.error_msg ( _("Can't start IVS, please add iTALC support") ) self.main.common.threads_leave("TcosActions:start_ivs write error msg") return
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)))
def askfor(self, mode="mess", msg="", users=None, users_txt=None): if users == None or users_txt == None: users=[] self.ask_usernames=[] if len(users) == 0 or users[0] == shared.NO_LOGIN_MSG: shared.error_msg( _("Clients not connected") ) return else: self.ask_usernames=users #users_txt="" #counter=1 #for user in self.ask_usernames: # users_txt+="%s, " %(user) # print_debug("askfor() counter=%s" %(counter) ) # if counter % 4 == 0: # users_txt+="\n" # counter=int(counter+1) #if users_txt[-2:] == "\n": users_txt=users_txt[:-2] #if users_txt[-2:] == ", ": users_txt=users_txt[:-2] if mode == "exec": # enable drag & drop self.main.ask_fixed.show() self.main.ask_dragdrop.show() self.main.image_entry.show() self.main.image_entry.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4) self.main.ask_label.set_markup( _("<b>Exec app in user(s) screen(s)\nor open web address to:</b>\n%s" ) %( users_txt ) ) elif mode == "mess": self.main.ask_label.set_markup( _("<b>Send a message to:</b>\n%s" ) %( users_txt ) ) elif mode == "any": self.main.ask_label.set_markup( msg ) self.ask_mode=mode self.main.ask.show() return True
def on_drag_data_received( self, widget, context, x, y, selection, targetType, dtime): files = selection.data.split('\n', 1) start1=time() print_debug("on_drag_data_received() files=%s dtime=%s"%(files, dtime)) for f in files: if f: desktop = f.strip().replace('%20', ' ') break if desktop.startswith('file:///') and desktop.lower().endswith('.desktop') and os.path.isfile(desktop[7:]): print_debug("open_file() reading data from \"%s\"..." \ %(desktop[7:]) ) fd=file(desktop[7:], 'r') data=fd.readlines() fd.close() # try to load gnome theme with gconf mytheme=[] theme=self.main.common.get_icon_theme() print_debug("on_drag_data_received() gconf theme=%s"%theme) str_image="" files=[] if theme and os.path.isdir("/usr/share/icons/%s"%theme): files+=glob.glob("/usr/share/icons/%s/48x48/*.png"%(theme)) files+=glob.glob("/usr/share/icons/hicolor/48x48/*/*.png") + \ glob.glob("/usr/share/icons/gnome/48x48/*/*.png") + \ glob.glob("/usr/share/pixmaps/*png") +\ glob.glob("/usr/share/pixmaps/*xpm") for line in data: if line != '\n': if line.startswith("Exec="): line=line.replace('\n', '') action, str_exec=line.split("=",1) str_exec=str_exec.replace("%U","").replace("%u","").replace("%F","").replace("%f","").replace("%c","").replace("%i","").replace("%m","") elif line.startswith("Icon="): line=line.replace('\n', '') action, image_name=line.split("=",1) if not os.path.isfile(image_name): start2=time() for f in files: if image_name in f or image_name.replace('_', '-') in f: str_image=f crono(start2, "on_drag_data_received() ICON FOUND AT %s"%f ) break else: str_image=image_name if len(str_exec) <1: shared.error_msg( _("%s is not application") %(os.path.basename(desktop[7:])) ) else: if len(str_image) <1: print_debug("on_drag_data_received() image '%s' not found"%image_name) self.main.image_entry.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4) else: self.main.image_entry.set_from_file(str_image) self.main.ask_entry.set_text(str_exec) else: shared.error_msg( _("%s is not application") %(os.path.basename(desktop[7:])) ) crono(start1, "on_drag_data_received() end" ) return True
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 start_vnc(self, ip): # force kill x11vnc in client self.main.xmlrpc.newhost(ip) host=self.main.localdata.GetHostname(self.main.selected_ip) max_wait=5 wait=0 self.main.common.threads_enter("TcosActions:start_vnc print status msg") self.main.write_into_statusbar( _("Connecting with %s to start VNC support") %(host) ) self.main.common.threads_leave("TcosActions:start_vnc print status msg") 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 # gen password in thin client passwd=''.join( Random().sample(string.letters+string.digits, 12) ) self.main.xmlrpc.vnc("genpass", ip, passwd) os.system("x11vnc -storepasswd %s %s >/dev/null 2>&1" \ %(passwd, os.path.expanduser('~/.tcosvnc')) ) try: # before starting server, vnc-controller.sh exec killall x11vnc, not needed to stop server #self.main.xmlrpc.vnc("stopserver", ip ) result=self.main.xmlrpc.vnc("startserver", ip) if result.find("error") != -1: self.main.common.threads_enter("TcosActions:start_vnc print error msg") shared.error_msg ( _("Can't start VNC, error:\n%s") %(result) ) self.main.common.threads_leave("TcosActions:start_vnc print error msg") return self.main.common.threads_enter("TcosActions:start_vnc print waiting msg") self.main.write_into_statusbar( _("Waiting for start of VNC server...") ) self.main.common.threads_leave("TcosActions:start_vnc print waiting msg") # need to wait for start, PingPort loop status = "CLOSED" 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": #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": # cmd = ("vncviewer " + ip + " -UseLocalCursor=0 -passwd %s" %os.path.expanduser('~/.tcosvnc') ) #else: # cmd = ("vncviewer " + ip + " -passwd %s" %os.path.expanduser('~/.tcosvnc') ) #print_debug ( "start_process() threading \"%s\"" %(cmd) ) #self.main.common.exe_cmd (cmd, verbose=0, background=True) self.main.common.threads_enter("TcosActions:start_vnc print x11vnc support msg") self.vncviewer(ip, passwd) self.main.common.threads_leave("TcosActions:start_vnc print x11vnc support msg") except Exception, err: print_debug("start_vnc() Exception, error=%s"%err) traceback.print_exc(file=sys.stderr) self.main.common.threads_enter("TcosActions:start_vnc print x11vnc support msg") shared.error_msg ( _("Can't start VNC, please add X11VNC support") ) self.main.common.threads_leave("TcosActions:start_vnc print x11vnc support msg") return
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} )
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 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} )
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 __init__(self, host): self.host=host self.name="TcosVolumeManager" self.visible=False if hasattr(gtk, 'status_icon_new_from_file'): # use gtk.status_icon icon = gtk.status_icon_new_from_file(shared.IMG_DIR + "tcos-volume-32x32.png") icon.set_tooltip( _("Tcos Sound levels on:\n%s") %(self.host) ) icon.connect("activate", self.on_tray_icon_press_event) else: shared.error_msg( _("ERROR: No tray icon support") ) sys.exit(1) from tcosmonitor.ping import PingPort if PingPort(self.host, shared.xmlremote_port, 0.5).get_status() != "OPEN": shared.error_msg( _("ERROR: It appears that TcosXmlRpc is not running on %s.") %(self.host) ) sys.exit(1) import tcosmonitor.TcosXauth self.xauth=tcosmonitor.TcosXauth.TcosXauth(self) self.xauth.init_standalone() # get all channels import tcosmonitor.TcosXmlRpc import tcosmonitor.TcosConf self.config=tcosmonitor.TcosConf.TcosConf(self, openfile=False) self.xmlrpc=tcosmonitor.TcosXmlRpc.TcosXmlRpc(self) nossl=True # make a test and exit if no cookie match if not self.xauth.test_auth(nossl): print ("tcos-volume-manager: ERROR: Xauth cookie don't match") #sys.exit(1) self.xmlrpc.newhost(self.host,nossl) if not self.xmlrpc.connected: shared.error_msg( _("Error connecting with TcosXmlRpc in %s.") %(self.host) ) sys.exit(1) # check for enabled sound have_sound=self.xmlrpc.IsEnabled("TCOS_SOUND") if not have_sound: print ("tcos-volume-manager: TCOS_SOUND is disabled") sys.exit(0) self.allchannels=self.xmlrpc.GetSoundChannelsContents() print_debug ("__init__() %s" %( self.allchannels ) ) self.ui = gtk.Builder() self.ui.set_translation_domain(shared.PACKAGE) # Widgets self.ui.add_from_file(shared.GLADE_DIR + 'tcos-volume-manager.ui') self.mainwindow = self.ui.get_object('mainwindow') # close windows signals #self.mainwindow.connect('destroy', self.quitapp ) self.mainwindow.connect('delete-event', self.mainwindow_close ) self.mainlabel=self.ui.get_object('mainlabel') self.scrolledwindow=self.ui.get_object('scrolledwindow') self.scrolledwindow2=self.ui.get_object('scrolledwindow2') self.quitbutton=self.ui.get_object('quitbutton') self.quitbutton.connect('clicked', self.quitapp ) self.statusbar=self.ui.get_object('statusbar') self.refreshbutton=self.ui.get_object('refreshbutton') self.refreshbutton.connect('clicked', self.on_refresh_button ) self.restartbutton=self.ui.get_object('restartbutton') self.restartbutton.connect('clicked', self.on_restart_button ) # only show if we found this file in $HOME dir allowfile=os.path.expanduser("~/.tcos-volume-manager.allow.restartpulse") if os.path.isfile(allowfile): self.restartbutton.show() # restart on start restartfile=os.path.expanduser("~/.tcos-volume-manager.start.restartpulse") if os.path.isfile(restartfile): self.xmlrpc.RestartSoundDaemon() # FIXME try to not focus on quitbutton self.refreshbutton.grab_focus() self.get_channel_info()