summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-config/mv_network.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2012-08-15 16:13:51 (GMT)
committerJames Meyer <james.meyer@operamail.com>2012-08-15 16:13:51 (GMT)
commit4989e79abe0bd9b8c7e364953158e66578f0b0d4 (patch)
tree38c0d1fe29ea2b8b4c4dd9aac56eb41b73a552a0 /abs/core/LinHES-config/mv_network.py
parent094bbec4072b32b2d9d81fb94fd262f60611f7e8 (diff)
downloadlinhes_pkgbuild-4989e79abe0bd9b8c7e364953158e66578f0b0d4.zip
linhes_pkgbuild-4989e79abe0bd9b8c7e364953158e66578f0b0d4.tar.gz
linhes_pkgbuild-4989e79abe0bd9b8c7e364953158e66578f0b0d4.tar.bz2
LinHES-config: fixed several install problems
- new grub install - fix detection of ip in python scripts - fix xscreensaver not starting after install - fix force umount of /new_boot
Diffstat (limited to 'abs/core/LinHES-config/mv_network.py')
-rwxr-xr-xabs/core/LinHES-config/mv_network.py43
1 files changed, 31 insertions, 12 deletions
diff --git a/abs/core/LinHES-config/mv_network.py b/abs/core/LinHES-config/mv_network.py
index aab1345..d0fa16c 100755
--- a/abs/core/LinHES-config/mv_network.py
+++ b/abs/core/LinHES-config/mv_network.py
@@ -18,17 +18,32 @@ def setup_MYTH_DHCP(systemconfig):
return defaultdhcp
def all_interfaces():
- max_possible = 128 # arbitrary. raise if needed.
- bytes = max_possible * 32
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- names = array.array('B', '\0' * bytes)
- outbytes = struct.unpack('iL', fcntl.ioctl(
- s.fileno(),
- 0x8912, # SIOCGIFCONF
- struct.pack('iL', bytes, names.buffer_info()[0])
- ))[0]
- namestr = names.tostring()
- return [namestr[i:i+32].split('\0', 1)[0] for i in range(0, outbytes, 32)]
+ # read the file /proc/net/dev
+ ifacelist=[]
+ returnlist=[]
+ try:
+ f = open('/proc/net/dev','r')
+ # put the content to list
+ ifacelist = f.read().split('\n')
+ # close the file
+ f.close()
+ # remove 2 lines header
+ ifacelist.pop(0)
+ ifacelist.pop(0)
+ except:
+ logging.critical(" *Problem reading /proc/net/dev")
+
+ # loop to check each line
+ for line in ifacelist:
+ ifacedata = line.replace(' ','').split(':')
+ # check the data have 2 elements
+ if len(ifacedata) == 2:
+ # check the interface is up (Transmit/Receive data)
+ if int(ifacedata[1]) > 0:
+ #print ifacedata[0]
+ returnlist.append(ifacedata[0])
+
+ return returnlist
def get_ip(ifname):
logging.debug(" Finding ip address for %s", ifname)
@@ -43,12 +58,16 @@ def get_ip(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- return socket.inet_ntoa(fcntl.ioctl(
+
+ ip = socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])
+ logging.debug(" get_ip ip address is %s", ip)
+ return ip
+
def get_default_route(iface):
rcroute = "127.0.0.1"
f = open ('/proc/net/route', 'r')