X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FComponents%2FAbout.py;h=4b6140696ecc26a9d817a774dfdb6f23f1e2850c;hp=8e332e3381c85b8b5d565fc33caa92230e404e45;hb=0fee8bdaa26f854460b63475c91f1f2cf762594b;hpb=e03708b0a361c236d7034f35e4585edd4a91bb34 diff --git a/lib/python/Components/About.py b/lib/python/Components/About.py old mode 100644 new mode 100755 index 8e332e3..4b61406 --- a/lib/python/Components/About.py +++ b/lib/python/Components/About.py @@ -1,5 +1,6 @@ from Tools.Directories import resolveFilename, SCOPE_SYSETC from enigma import getEnigmaVersionString +from os import popen class About: def __init__(self): @@ -43,4 +44,72 @@ class About: def getEnigmaVersionString(self): return getEnigmaVersionString() + def getKernelVersionString(self): + try: + result = popen("uname -r","r").read().strip("\n").split('-') + kernel_version = result[0] + return kernel_version + except: + pass + + return "unknown" + + def getIfaces(self): + import socket, fcntl, struct, array, sys + SIOCGIFCONF = 0x8912 # sockios.h + is_64bits = sys.maxsize > 2**32 + struct_size = 40 if is_64bits else 32 + max_possible = 8 # initial value + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + while True: + # ifconf structure: + # struct ifconf { + # int ifc_len; /* size of buffer */ + # union { + # char *ifc_buf; /* buffer address */ + # struct ifreq *ifc_req; /* array of structures */ + # }; + # }; + # + # struct ifreq: + # #define IFNAMSIZ 16 + # struct ifreq { + # char ifr_name[IFNAMSIZ]; /* Interface name */ + # union { + # struct sockaddr ifr_addr; + # ..... + # }; + # }; + + # Initialize ifc_buf + bytes = max_possible * struct_size + names = array.array('B') + for i in range(0, bytes): + names.append(0) + + input_buffer = struct.pack( 'iL', bytes, names.buffer_info()[0] ) + output_buffer = fcntl.ioctl( sock.fileno(), SIOCGIFCONF, input_buffer ) + output_size = struct.unpack('iL', output_buffer)[0] + + if output_size == bytes: + max_possible *= 2 + else: + break + + namestr = names.tostring() + ifaces = [] + for i in range(0, output_size, struct_size): + iface_name = namestr[i:i+16].split('\0', 1)[0] + iface_addr = socket.inet_ntoa(namestr[i+20:i+24]) + if iface_name != 'lo': + ifaces.append((iface_name, iface_addr)) + + return ifaces + + def getNetworkInfo(self): + data = "" + for x in self.getIfaces(): + data += "%s : %s\n" % (x[0], x[1]) + return data or "\tnot connected" + about = About()