Permalink
Browse files

rebased on dev branch.

  • Loading branch information...
1 parent 1769f8d commit e4e22bfd4479895f6222f2676af3113a9fd52b21 @Shanto committed Dec 3, 2011
Showing with 23 additions and 18 deletions.
  1. +23 −18 plugins/network/nctp_linux.py
@@ -35,31 +35,37 @@ def get_info(self, iface):
return ui
def get_tx(self, iface):
- s = shell('ifconfig %s | grep \'TX bytes\''%iface.name)
- print s
try:
- s = s.split()[5].split(':')[1]
- except:
- s = '0'
- return int(s)
+ return int(shell('ifconfig %s | grep \'TX bytes\''%iface.name).split()[5].split(':')[1])
+ except: pass
+
+ try:
+ return int(shell('ifconfig %s | grep -E \'TX .+ bytes\''%iface.name).split()[4])
+ except: pass
+
+ return 0
def get_rx(self, iface):
- s = shell('ifconfig %s | grep \'RX bytes\''%iface.name)
- print s
try:
- s = s.split()[1].split(':')[1]
- except:
- s = '0'
- return int(s)
+ return int(shell('ifconfig %s | grep \'RX bytes\''%iface.name).split()[1].split(':')[1])
+ except: pass
+
+ try:
+ return int(shell('ifconfig %s | grep -E \'RX .+ bytes\''%iface.name).split()[4])
+ except: pass
+
+ return 0
def get_ip(self, iface):
- s = shell('ifconfig %s | grep \'inet addr\''%iface.name)
try:
- s = s.split()[1].split(':')[1]
- except:
- s = '0.0.0.0'
- return s
+ return shell('ifconfig %s | grep \'inet addr\''%iface.name).split()[1].split(':')[1]
+ except: pass
+
+ try:
+ return shell('ifconfig %s | grep \'inet\''%iface.name).split()[1]
+ except: pass
+ return '0.0.0.0'
def detect_dev_class(self, iface):
if iface.name[:-1] in ['ppp', 'wvdial']:
@@ -79,7 +85,6 @@ def detect_dev_class(self, iface):
def detect_iface_bits(self, iface):
r = ['linux-basic']
cls = self.detect_dev_class(iface)
- print iface.type, iface.addressing
if iface.type == 'inet' and iface.addressing == 'static':
r.append('linux-ipv4')
if iface.type == 'inet6' and iface.addressing == 'static':

0 comments on commit e4e22bf

Please sign in to comment.