Changeset 949
- Timestamp:
- 08/07/08 15:00:43 (4 months ago)
- Location:
- trunk/tcosmonitor
- Files:
-
- 4 modified
-
TcosCommon.py (modified) (8 diffs)
-
debian/changelog (modified) (1 diff)
-
debian/control (modified) (1 diff)
-
ping.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tcosmonitor/TcosCommon.py
r944 r949 34 34 from gettext import gettext as _ 35 35 36 import netifaces 36 37 37 38 from time import sleep … … 112 113 def get_ip_address(self, ifname): 113 114 print_debug("get_ip_address() ifname=%s" %(ifname) ) 115 if not ifname in netifaces.interfaces(): 116 return None 117 ip=netifaces.ifaddresses(ifname) 118 if ip.has_key(netifaces.AF_INET): 119 return ip[netifaces.AF_INET][0]['addr'] 120 return None 121 """ 122 old code 123 print_debug("get_ip_address() ifname=%s" %(ifname) ) 114 124 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 115 125 #print_debug("get_ip_address() iface=%s" %ifname) … … 119 129 struct.pack('256s', ifname[:15]) 120 130 )[20:24]) 131 """ 121 132 122 133 def GetAllNetworkInterfaces(self): 134 self.vars["allnetworkinterfaces"]=[] 135 for dev in netifaces.interfaces(): 136 if not dev in shared.hidden_network_ifaces: 137 self.vars["allnetworkinterfaces"].append(dev) 138 ip=netifaces.ifaddresses(dev) 139 print_debug ( "GetAllNetworkInterfaces() %s" %( self.vars["allnetworkinterfaces"] ) ) 140 return self.vars["allnetworkinterfaces"] 141 """ 123 142 self.vars["allnetworkinterfaces"]=[] 124 143 d="/sys/class/net/" … … 129 148 print_debug ( "GetAllNetworkInterfaces() %s" %( self.vars["allnetworkinterfaces"] ) ) 130 149 return self.vars["allnetworkinterfaces"] 150 """ 131 151 132 152 def get_my_local_ip(self, last=True, force=False): … … 135 155 self.vars["local_ip"]=[] 136 156 for dev in self.GetAllNetworkInterfaces(): 157 ip=self.get_ip_address(dev) 158 if ip: 159 self.vars["local_ip"].append(ip) 160 """ 137 161 try: 138 162 ip=self.get_ip_address(dev) … … 141 165 print_debug("get_my_local_ip() Exception, dev=%s error=%s"%(dev,err) ) 142 166 pass 167 """ 143 168 if last: 144 169 return self.vars["local_ip"][0] … … 150 175 if "local_ip" in self.vars: 151 176 return self.vars["local_ip"] 152 return get_my_local_ip(last=False)177 return self.get_my_local_ip(last=False) 153 178 154 179 def get_display(self, ip_mode=True): … … 249 274 #print app.get_all_my_ips() 250 275 #print app.get_extensions() 251 app.init_all_extensions(extfilter="menu_one") 252 print app.get_icon_theme() 276 #app.init_all_extensions(extfilter="menu_one") 277 #print app.get_icon_theme() 278 #print app.get_all_my_ips() 279 #print app.GetAllNetworkInterfaces() 280 print app.get_ip_address('eth0') 281 print app.get_ip_address('eth1') 282 print app.get_ip_address('br0') 283 print app.get_ip_address('br0:0') -
trunk/tcosmonitor/debian/changelog
r948 r949 1 tcosmonitor (0.2.16~rc5) unstable; urgency=low 2 3 * ping.py TcosCommon.py debian/control: 4 - Replace old code to get interfaces and IP addr with python-netifaces (in TCOS mirror) 5 6 -- Mario Izquierdo (mariodebian) <mariodebian@gmail.com> Thu, 07 Aug 2008 14:58:45 +0200 7 1 8 tcosmonitor (0.2.16~rc4) unstable; urgency=low 2 9 -
trunk/tcosmonitor/debian/control
r914 r949 13 13 Architecture: all 14 14 Depends: gksu | kdebase-bin, zenity, dbus, 15 python-dbus | python2.4-dbus, python-gtk2, python-glade2, 15 python-dbus | python2.4-dbus, python-gtk2, python-glade2, python-netifaces, 16 16 x11vnc, lsb-base (>= 3.0-6), python-notify, python-gnome2-extras, 17 17 notification-daemon, libnotify-bin, tcos-core ( >= 0.89~rc0), python-utmp, -
trunk/tcosmonitor/ping.py
r944 r949 20 20 from time import sleep 21 21 from subprocess import Popen, PIPE, STDOUT 22 23 import netifaces 22 24 23 25 if "DISPLAY" in os.environ: … … 137 139 138 140 def get_ip_address(self, ifname): 141 print_debug("get_ip_address() ifname=%s" %(ifname) ) 142 if not ifname in netifaces.interfaces(): 143 return None 144 ip=netifaces.ifaddresses(ifname) 145 if ip.has_key(netifaces.AF_INET): 146 return ip[netifaces.AF_INET][0]['addr'] 147 return None 148 """ 149 old code 139 150 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 140 151 try: … … 148 159 print_debug("get_ip_address() ifname %s don't have ip address, error=%s"%(ifname,err)) 149 160 return ip 161 """ 150 162 151 163 152 164 def get_server_ips(self): 165 IPS=[] 166 for dev in netifaces.interfaces(): 167 if not dev in shared.hidden_network_ifaces: 168 print_debug("get_server_ips() add interface %s"%dev) 169 ip=netifaces.ifaddresses(dev) 170 if ip.has_key(netifaces.AF_INET): 171 print_debug("get_server_ips() iface=%s data=%s"%(dev,ip[netifaces.AF_INET] )) 172 IPS.append(ip[netifaces.AF_INET][0]['addr']) 173 return IPS 174 """ 175 old code 153 176 IPS=[] 154 177 for dev in os.listdir("/sys/class/net"): … … 162 185 print_debug("get_server_ips() IPS=%s"%IPS) 163 186 return IPS 187 """ 164 188 165 189 … … 231 255 #PingPort("192.168.0.5", 6000, 0.5).get_status() 232 256 #PingPort("192.168.0.1", 6000, 0.5).get_status() 233 PingPort(sys.argv[1], sys.argv[2], 0.5).get_status() 234 #app=Ping(None) 235 #print app.get_server_ips() 257 #PingPort(sys.argv[1], sys.argv[2], 0.5).get_status() 258 app=Ping(None) 259 print app.get_server_ips() 260 print app.get_ip_address('eth0') 261 print app.get_ip_address('br0') 262
