Changeset 944 for trunk/tcosmonitor/TcosActions.py
- Timestamp:
- 08/06/08 19:52:38 (5 months ago)
- Files:
-
- 1 modified
-
trunk/tcosmonitor/TcosActions.py (modified) (37 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tcosmonitor/TcosActions.py
r931 r944 53 53 print_debug ( "__init__()" ) 54 54 self.main=main 55 self.model=self.main.init.model55 #self.model=self.main.init.model 56 56 #self.main.progressstop_args={} 57 57 … … 101 101 print_debug ( "on_another_screenshot_button_click() __init__ ip=%s" %(ip) ) 102 102 self.main.worker=shared.Workers(self.main, target=self.get_screenshot, args=[ip]) 103 self.main.worker.start() 104 105 def on_rightclickmenuone_click(self, menu, number): 106 print_debug ( "on_rightclickmenuone_click() => onehost_menuitems[%d]=%s" \ 107 % (number, shared.onehost_menuitems[number][0]) ) 108 self.menu_event_one(number) 103 self.main.worker.start() 109 104 110 105 def on_allhostbutton_click(self, widget): … … 113 108 self.main.allmenu.popup( None, None, None, event.button, event.time) 114 109 return True 115 116 def on_rightclickmenuall_click(self, menu, number):117 print_debug ( "on_rightclickmenuall_click() => allhost_menuitems[%d]=%s" \118 % (number, shared.allhost_menuitems[number][0]) )119 self.menu_event_all(number)120 110 121 111 def on_preferencesbutton_click(self,widget): … … 173 163 if len(allclients) == 0: 174 164 self.main.write_into_statusbar ( _("Not connected hosts found.") ) 175 # clean treeview 176 model=self.main.tabla.get_model() 177 model.clear() 165 # clean icons and files 166 self.main.listview.clear() 178 167 self.main.iconview.clear() 179 168 self.main.classview.clear() … … 230 219 return self.main.updating 231 220 232 233 def on_hostlist_click(self, hostlist):234 if self.main.worker_running:235 return236 237 self.main.progressbar.hide()238 (model, iter) = hostlist.get_selected()239 if not iter:240 return241 self.main.selected_host=model.get_value(iter,COL_HOST)242 self.main.selected_ip=model.get_value(iter, COL_IP)243 244 print_debug ( "on_hostlist_clic() selectedhost=%s selectedip=%s" \245 %(self.main.selected_host, self.main.selected_ip) )246 247 # call to read remote info248 #self.main.localdata.newhost(self.main.selected_ip)249 self.main.xmlrpc.newhost(self.main.selected_ip)250 self.main.xmlrpc.ip=self.main.selected_ip251 if not self.main.xmlrpc.isPortListening(self.main.selected_ip, self.main.xmlrpc.lastport):252 print_debug ( "on_host_list_click() XMLRPC not running in %s" %(self.main.selected_ip) )253 self.main.write_into_statusbar ( _("Error connecting to tcosxmlrpc in %s") %(self.main.selected_ip) )254 return255 256 print_debug ( "on_host_list_click() AUTH OK" )257 258 self.main.write_into_statusbar ( "" )259 print_debug ( "on_hostlist_click() callig worker to populate in Thread" )260 261 self.main.worker=shared.Workers( self.main,\262 target=self.populate_datatxt, args=([self.main.selected_ip]) ).start()263 264 return265 221 266 222 def askwindow_close(self, widget, event): … … 514 470 515 471 # print into statusbar 516 #gtk.gdk.threads_enter()517 472 self.main.common.threads_enter("TcosActions:populate_datatxt show progressbar") 518 473 519 if shared.disable_textview_on_update: self.main.tabla.set_sensitive(False) 474 if shared.disable_textview_on_update and self.main.iconview.isactive(): 475 self.main.tabla.set_sensitive(True) 520 476 521 477 #self.main.write_into_statusbar( _("Connecting with %s to retrieve some info..." ) %(ip) ) … … 524 480 #self.main.progressbutton.show() 525 481 self.set_progressbar( _("Connecting with %s to retrieve some info..." ) %(ip) , 0 ,show_percent=False) 526 #gtk.gdk.threads_leave()482 527 483 self.main.common.threads_leave("TcosActions:populate_datatxt show progressbar") 528 484 … … 758 714 try: 759 715 (key,value)=data.split('=') 760 except: 716 except Exception, err: 717 print_debug("populate_datatxt() Exception spliting data=%s, err=%s"%(data,err)) 761 718 key=data 762 719 value="" … … 844 801 try: 845 802 value=float(value) 846 except: 803 except Exception, err: 804 print_debug("populate_datatxt() Exception getting volume=%s, err=%s"%(value,err) ) 847 805 value=0.0 848 806 … … 945 903 self.datatxt.insert_block ( _("Sound server is not running"), image=shared.IMG_DIR + "info_sound_ko.png") 946 904 947 #gtk.gdk.threads_enter()948 905 self.main.common.threads_enter("TcosActions:populate_datatxt end") 949 906 self.datatxt.display() … … 951 908 self.main.progressbar.hide() 952 909 953 if shared.disable_textview_on_update : self.main.tabla.set_sensitive(True)954 955 #gtk.gdk.threads_leave()910 if shared.disable_textview_on_update and self.main.iconview.isactive(): 911 self.main.tabla.set_sensitive(True) 912 956 913 self.main.common.threads_leave("TcosActions:populate_datatxt end") 957 914 … … 999 956 print_debug ( "populate_hostlist() clear list and start progressbar!!!" ) 1000 957 1001 #gtk.gdk.threads_enter()1002 958 self.main.common.threads_enter("TcosActions:populate_hostlist show progressbar") 1003 959 1004 if shared.disable_textview_on_update: self.main.tabla.set_sensitive(False) 960 if shared.disable_textview_on_update and self.main.iconview.isactive(): 961 self.main.tabla.set_sensitive(True) 1005 962 1006 963 #disable refresh button … … 1009 966 self.main.progressbutton.show() 1010 967 self.set_progressbar( _("Searching info of hosts..."), 0) 1011 self.model.clear() 968 if self.main.listview.isenabled(): 969 self.main.listview.clear() 1012 970 if self.main.iconview.isenabled(): 1013 self.main.iconview.clear()971 self.main.iconview.clear() 1014 972 if self.main.classview.isenabled(): 1015 self.main.classview.clear() 1016 #gtk.gdk.threads_leave() 973 self.main.classview.clear() 1017 974 self.main.common.threads_leave("TcosActions:populate_hostlist show progressbar") 1018 975 … … 1036 993 print_debug ( "populate_hostlist() WORKER IS STOPPED" ) 1037 994 break 1038 except: 995 except Exception, err: 996 print_debug("populate_hostlist() can't read worker status, error=%s"%err) 1039 997 pass 1040 998 i += 1 1041 #gtk.gdk.threads_enter()1042 999 self.main.common.threads_enter("TcosActions:populate_hostlist show connecting") 1043 1000 self.main.progressbar.show() 1044 self.set_progressbar( _("Connecting to %s...") \ 1045 %(host), float(i)/float(len(clients)) ) 1046 #gtk.gdk.threads_leave() 1001 self.set_progressbar( _("Connecting to %s...") %(host), float(i)/float(len(clients)) ) 1047 1002 self.main.common.threads_leave("TcosActions:populate_hostlist show connecting") 1048 1003 … … 1051 1006 self.main.xmlrpc.newhost (host) 1052 1007 1053 ip=host 1054 standalone=False 1055 logged=False 1008 data={} 1009 data['host']=host 1010 data['ip']=host 1011 data['standalone']=False 1012 data['logged']=False 1056 1013 print_debug("populate_hostlist() => get username") 1057 username=self.main.localdata.GetUsername(ip)1014 data['username']=self.main.localdata.GetUsername(data['ip']) 1058 1015 1059 1016 if shared.dont_show_users_in_group != None: 1060 if self.main.xmlrpc.IsStandalone( ip):1017 if self.main.xmlrpc.IsStandalone(data['ip']): 1061 1018 groupexclude=self.main.xmlrpc.GetStandalone("get_exclude", shared.dont_show_users_in_group) 1062 1019 else: 1063 groupexclude=self.main.localdata.isExclude( ip, shared.dont_show_users_in_group)1020 groupexclude=self.main.localdata.isExclude(data['ip'], shared.dont_show_users_in_group) 1064 1021 1065 1022 if groupexclude: 1066 print_debug("Host %s excluded, blacklisted by group" % ip)1023 print_debug("Host %s excluded, blacklisted by group" %data['ip']) 1067 1024 continue 1068 1025 1069 1026 print_debug("populate_hostlist() => get hostname") 1070 hostname=self.main.localdata.GetHostname(ip)1071 1072 if username.startswith('error: tcos-last'):1073 username="---"1027 data['hostname']=self.main.localdata.GetHostname(data['ip']) 1028 1029 if data['username'].startswith('error: tcos-last'): 1030 data['username']="---" 1074 1031 1075 1032 try: 1076 1033 print_debug("populate_hostlist() => get num process") 1077 num_process=self.main.localdata.GetNumProcess(ip) 1078 except: 1079 num_process="---" 1034 data['num_process']=self.main.localdata.GetNumProcess(data['ip']) 1035 except Exception, err: 1036 print_debug("populate_hostlist() Exception getting num process, error=%s"%err) 1037 data['num_process']="---" 1080 1038 1081 1039 print_debug("populate_hostlist() => get time logged") 1082 if self.main.xmlrpc.IsStandalone( ip):1083 time_logged=self.main.xmlrpc.GetStandalone("get_time")1084 standalone=True1040 if self.main.xmlrpc.IsStandalone(data['ip']): 1041 data['time_logged']=self.main.xmlrpc.GetStandalone("get_time") 1042 data['standalone']=True 1085 1043 else: 1086 time_logged=self.main.localdata.GetTimeLogged(ip)1087 standalone=False1088 1089 if not time_logged or time_logged == "" or time_logged.startswith('error: tcos-last'):1090 time_logged="---"1044 data['time_logged']=self.main.localdata.GetTimeLogged(data['ip']) 1045 data['standalone']=False 1046 1047 if not data['time_logged'] or data['time_logged'] == "" or data['time_logged'].startswith('error: tcos-last'): 1048 data['time_logged']="---" 1091 1049 1092 1050 print_debug("populate_hostlist() => get active connection") 1093 if self.main.localdata.IsActive(ip): 1051 if self.main.localdata.IsActive(data['ip']): 1052 data['active']=True 1094 1053 if self.main.xmlrpc.sslconnection: 1095 image_active=active_ssl_image1054 data['image_active']=active_ssl_image 1096 1055 else: 1097 image_active=active_image1056 data['image_active']=active_image 1098 1057 else: 1099 image_active=inactive_image 1058 data['image_active']=inactive_image 1059 data['active']=False 1100 1060 1101 1061 print_debug("populate_hostlist() => get is logged") 1102 if self.main.localdata.IsLogged( ip):1103 image_logged=logged_image1104 logged=True1062 if self.main.localdata.IsLogged(data['ip']): 1063 data['image_logged']=logged_image 1064 data['logged']=True 1105 1065 else: 1106 image_logged=unlogged_image1107 logged=False1066 data['image_logged']=unlogged_image 1067 data['logged']=False 1108 1068 1109 1069 print_debug("populate_hostlist() => get is blocked") 1110 if self.main.localdata.IsBlocked( host):1111 blocked_screen=True1070 if self.main.localdata.IsBlocked(data['ip']): 1071 data['blocked_screen']=True 1112 1072 else: 1113 blocked_screen=False1073 data['blocked_screen']=False 1114 1074 1115 1075 print_debug("populate_hostlist() => get is blocked net") 1116 if self.main.localdata.IsBlockedNet(host, username):1117 blocked_net=True1076 if self.main.localdata.IsBlockedNet(host,data['username']): 1077 data['blocked_net']=True 1118 1078 else: 1119 blocked_net=False1120 1121 if blocked_screen and blocked_net:1122 image_blocked=locked_net_screen_image1123 elif blocked_screen == False and blocked_net:1124 image_blocked=locked_net_image1125 elif blocked_screen and blocked_net== False:1126 image_blocked=locked_image1079 data['blocked_net']=False 1080 1081 if data['blocked_screen'] and data['blocked_net']: 1082 data['image_blocked']=locked_net_screen_image 1083 elif data['blocked_screen'] == False and data['blocked_net']: 1084 data['image_blocked']=locked_net_image 1085 elif data['blocked_screen'] and data['blocked_net'] == False: 1086 data['image_blocked']=locked_image 1127 1087 else: 1128 image_blocked=unlocked_image 1129 1130 data={'ip':ip, 'hostname':hostname, 'host':host, 1131 'standalone':standalone, 'username':username, 1132 'blocked_screen':blocked_screen, 'blocked_net': blocked_net, 1133 'logged':logged, 'time_logged':time_logged} 1088 data['image_blocked']=unlocked_image 1089 1090 1091 if self.main.listview.isactive(): 1092 self.main.common.threads_enter("TcosActions:populate_hostlist LIST generate_icon") 1093 self.main.listview.generate_file(data) 1094 self.main.common.threads_leave("TcosActions:populate_hostlist LIST generate_icon") 1134 1095 1135 1096 if self.main.iconview.isactive(): … … 1137 1098 self.main.iconview.generate_icon(data) 1138 1099 self.main.common.threads_leave("TcosActions:populate_hostlist ICON generate_icon") 1139 1100 1140 1101 if self.main.classview.isactive(): 1141 1102 self.main.common.threads_enter("TcosActions:populate_hostlist CLASS generate_icon") … … 1143 1104 self.main.common.threads_leave("TcosActions:populate_hostlist CLASS generate_icon") 1144 1105 1145 #gtk.gdk.threads_enter() 1146 self.main.common.threads_enter("TcosActions:populate_hostlist print data") 1147 self.iter = self.model.append (None) 1148 self.model.set_value (self.iter, COL_HOST, hostname ) 1149 self.model.set_value (self.iter, COL_IP, host ) 1150 self.model.set_value (self.iter, COL_USERNAME, username ) 1151 self.model.set_value (self.iter, COL_ACTIVE, image_active ) 1152 self.model.set_value (self.iter, COL_LOGGED, image_logged) 1153 self.model.set_value (self.iter, COL_BLOCKED, image_blocked) 1154 self.model.set_value (self.iter, COL_PROCESS, num_process ) 1155 self.model.set_value (self.iter, COL_TIME, time_logged) 1156 #gtk.gdk.threads_leave() 1157 self.main.common.threads_leave("TcosActions:populate_hostlist print data") 1158 1159 crono(start2, "populate_host_list(%s)" %(ip) ) 1160 1161 #gtk.gdk.threads_enter() 1106 1107 crono(start2, "populate_host_list(%s)" %(data['ip']) ) 1108 1162 1109 self.main.common.threads_enter("TcosActions:populate_hostlist END") 1163 1110 self.main.progressbar.hide() … … 1166 1113 self.main.progressbutton.set_sensitive(True) 1167 1114 1168 if shared.disable_textview_on_update : self.main.tabla.set_sensitive(True)1169 1170 #gtk.gdk.threads_leave()1115 if shared.disable_textview_on_update and self.main.iconview.isactive(): 1116 self.main.tabla.set_sensitive(True) 1117 1171 1118 self.main.common.threads_leave("TcosActions:populate_hostlist END") 1172 1119 1173 1120 try: 1174 1121 self.main.worker.set_finished() 1175 except: 1122 except Exception, err: 1123 print_debug("populate_hostlist() Exception setting worker status, err=%s" %err) 1176 1124 pass 1177 1125 crono(start1, "populate_host_list(ALL)" ) … … 1204 1152 self.main.selected_host=self.main.classview.get_host(self.main.selected_ip) 1205 1153 else: 1206 (model, iter) = self.main.tabla.get_selection().get_selected() 1207 if iter == None: 1208 print_debug( "menu_event_one() not selected thin client !!!" ) 1209 return 1210 self.main.selected_host=model.get_value(iter,COL_HOST) 1211 self.main.selected_ip=model.get_value(iter, COL_IP) 1154 self.main.selected_ip=self.main.listview.get_selected() 1155 self.main.selected_host=self.main.listview.get_host(self.main.selected_ip) 1156 #(model, iter) = self.main.tabla.get_selection().get_selected() 1157 #if iter == None: 1158 # print_debug( "menu_event_one() not selected thin client !!!" ) 1159 # return 1160 #self.main.selected_host=model.get_value(iter,COL_HOST) 1161 #self.main.selected_ip=model.get_value(iter, COL_IP) 1162 1163 if not self.main.selected_ip: 1164 # show a msg 1165 shared.error_msg ( _("Error: no IP!") ) 1166 return 1212 1167 1213 1168 if not self.doaction_onthisclient(action, self.main.selected_ip): … … 1677 1632 1678 1633 if self.main.config.GetVar("selectedhosts") == 1: 1679 allclients=[] 1680 model=self.main.tabla.get_model() 1681 rows = [] 1682 model.foreach(lambda model, path, iter: rows.append(path)) 1683 for host in rows: 1684 iter=model.get_iter(host) 1685 if model.get_value(iter, COL_SEL_ST): 1686 allclients.append(model.get_value(iter, COL_IP)) 1634 #allclients=[] 1635 #model=self.main.tabla.get_model() 1636 #rows = [] 1637 #model.foreach(lambda model, path, iter: rows.append(path)) 1638 #for host in rows: 1639 # iter=model.get_iter(host) 1640 # if model.get_value(iter, COL_SEL_ST): 1641 # allclients.append(model.get_value(iter, COL_IP)) 1642 allclients=self.main.listview.getmultiple() 1687 1643 if len(allclients) == 0: 1688 1644 msg=_( _("No clients selected, do you want to select all?" ) ) … … 1951 1907 max_wait=5 1952 1908 wait=0 1953 #gtk.gdk.threads_enter()1954 1909 self.main.common.threads_enter("TcosActions:start_vnc print status msg") 1955 1910 self.main.write_into_statusbar( _("Connecting with %s to start VNC support") %(host) ) 1956 #gtk.gdk.threads_leave()1957 1911 self.main.common.threads_leave("TcosActions:start_vnc print status msg") 1958 1912 … … 1982 1936 result=self.main.xmlrpc.vnc("startserver", ip) 1983 1937 if result.find("error") != -1: 1984 #gtk.gdk.threads_enter()1985 1938 self.main.common.threads_enter("TcosActions:start_vnc print error msg") 1986 1939 shared.error_msg ( _("Can't start VNC, error:\n%s") %(result) ) 1987 #gtk.gdk.threads_leave()1988 1940 self.main.common.threads_leave("TcosActions:start_vnc print error msg") 1989 1941 return 1990 #gtk.gdk.threads_enter()1991 1942 self.main.common.threads_enter("TcosActions:start_vnc print waiting msg") 1992 1943 self.main.write_into_statusbar( _("Waiting for start of VNC server...") ) 1993 #gtk.gdk.threads_leave()1994 1944 self.main.common.threads_leave("TcosActions:start_vnc print waiting msg") 1995 1945 … … 2015 1965 print_debug ( "start_process() threading \"%s\"" %(cmd) ) 2016 1966 self.main.common.exe_cmd (cmd, verbose=0, background=True) 2017 except :2018 #gtk.gdk.threads_enter()1967 except Exception, err: 1968 print_debug("start_vnc() Exception, error=%s"%err) 2019 1969 self.main.common.threads_enter("TcosActions:start_vnc print x11vnc support msg") 2020 1970 shared.error_msg ( _("Can't start VNC, please add X11VNC support") ) 2021 #gtk.gdk.threads_leave()2022 1971 self.main.common.threads_leave("TcosActions:start_vnc print x11vnc support msg") 2023 1972 return 2024 1973 2025 #gtk.gdk.threads_enter()2026 1974 self.main.common.threads_enter("TcosActions:start_vnc clean status msg") 2027 1975 self.main.write_into_statusbar( "" ) 2028 #gtk.gdk.threads_leave()2029 1976 self.main.common.threads_leave("TcosActions:start_vnc clean status msg") 2030 1977 … … 2034 1981 # check if remote proc is running 2035 1982 if not self.main.xmlrpc.GetStatus("ivs"): 2036 #gtk.gdk.threads_enter()2037 1983 self.main.common.threads_enter("TcosActions:start_ivs write connecting msg") 2038 1984 self.main.write_into_statusbar( "Connecting with %s to start iTALC support" %(ip) ) 2039 #gtk.gdk.threads_leave()2040 1985 self.main.common.threads_leave("TcosActions:start_ivs write connecting msg") 2041 1986 … … 2043 1988 self.main.xmlrpc.newhost(ip) 2044 1989 self.main.xmlrpc.Exe("startivs") 2045 #gtk.gdk.threads_enter()2046 1990 self.main.common.threads_enter("TcosActions:start_ivs write waiting msg") 2047 1991 self.main.write_into_statusbar( "Waiting for start of IVS server..." ) 2048 #gtk.gdk.threads_leave()2049 1992 self.main.common.threads_leave("TcosActions:start_ivs write waiting msg") 2050 1993 sleep(5) 2051 except :2052 #gtk.gdk.threads_enter()1994 except Exception, err: 1995 print_debug("start_ivs() Exception, error=%s"%err) 2053 1996 self.main.common.threads_enter("TcosActions:start_ivs write error msg") 2054 1997 shared.error_msg ( _("Can't start IVS, please add iTALC support") ) 2055 #gtk.gdk.threads_leave()2056 1998 self.main.common.threads_leave("TcosActions:start_ivs write error msg") 2057 1999 return … … 2061 2003 self.main.common.exe_cmd (cmd, verbose=0, background=True) 2062 2004 2063 #gtk.gdk.threads_enter()2064 2005 self.main.common.threads_enter("TcosActions:start_ivs END") 2065 2006 self.main.write_into_statusbar( "" ) 2066 #gtk.gdk.threads_leave()2067 2007 self.main.common.threads_leave("TcosActions:start_ivs END") 2068 2008 … … 2100 2040 if self.main.iconview.ismultiple(): 2101 2041 allclients=self.main.iconview.get_multiple() 2042 elif self.main.classview.ismultiple(): 2043 allclients=self.main.classview.get_multiple() 2102 2044 elif not self.main.iconview.isactive() and self.main.config.GetVar("selectedhosts") == 1: 2103 allclients=[] 2104 model=self.main.tabla.get_model() 2105 rows = [] 2106 model.foreach(lambda model, path, iter: rows.append(path)) 2107 for host in rows: 2108 iter=model.get_iter(host) 2109 if model.get_value(iter, COL_SEL_ST): 2110 allclients.append(model.get_value(iter, COL_IP)) 2045 #allclients=[] 2046 #model=self.main.tabla.get_model() 2047 #rows = [] 2048 #model.foreach(lambda model, path, iter: rows.append(path)) 2049 #for host in rows: 2050 # iter=model.get_iter(host) 2051 # if model.get_value(iter, COL_SEL_ST): 2052 # allclients.append(model.get_value(iter, COL_IP)) 2053 allclients=self.main.listview.getmultiple() 2111 2054 if len(allclients) == 0: 2112 2055 #msg=_( _("No clients selected, do you want to select all?" ) ) … … 2782 2725 mydict["action"]=action 2783 2726 mydict["ip"]=ip 2784 #gtk.gdk.threads_enter()2785 2727 self.main.common.threads_enter("TcosActions::action_for_clients doing action") 2786 2728 self.set_progressbar( _("Doing action \"%(action)s\" in %(ip)s...") %mydict , percent ) 2787 #gtk.gdk.threads_leave()2788 2729 self.main.common.threads_leave("TcosActions::action_for_clients doing action") 2789 2730 … … 2794 2735 self.main.xmlrpc.unlockscreen() 2795 2736 # update icon 2796 #gtk.gdk.threads_enter()2797 2737 self.main.common.threads_enter("TcosActions::action_for_clients unlockscreen") 2798 2738 self.change_lockscreen(ip) 2799 #gtk.gdk.threads_leave()2800 2739 self.main.common.threads_leave("TcosActions::action_for_clients unlockscreen") 2801 2740 elif action == "lockscreen": 2802 2741 self.main.xmlrpc.lockscreen() 2803 2742 # update icon 2804 #gtk.gdk.threads_enter()2805 2743 self.main.common.threads_enter("TcosActions::action_for_clients lockscreen") 2806 2744 self.change_lockscreen(ip) 2807 #gtk.gdk.threads_leave()2808 2745 &n
