|
|
|
@ -84,8 +84,10 @@ def checkMask(mask):
|
|
|
|
|
|
|
|
|
|
def getIpAndMask(interface="eth0"):
|
|
|
|
|
"""Get ip and mask from interface"""
|
|
|
|
|
ifconfig = process('/sbin/ifconfig',interface)
|
|
|
|
|
res = re.search(r"inet addr:(\S+)\s.*Mask:(\S+)",ifconfig.read(),re.S)
|
|
|
|
|
ipconfigProg = checkUtils('/sbin/ifconfig')
|
|
|
|
|
ifconfig = process(ipconfigProg,interface)
|
|
|
|
|
res = re.search(r"inet(?: addr:| )(\S+)\s.*(?:Mask:|netmask )(\S+)",
|
|
|
|
|
ifconfig.read(),re.S)
|
|
|
|
|
if res:
|
|
|
|
|
return res.groups()
|
|
|
|
|
else:
|
|
|
|
@ -139,7 +141,7 @@ def receiveMac(interface="eth0"):
|
|
|
|
|
"""Get MAC from interface"""
|
|
|
|
|
ipconfigProg = checkUtils('/sbin/ifconfig')
|
|
|
|
|
ifconfig = process(ipconfigProg,interface)
|
|
|
|
|
res = re.search(r"HWaddr\s(\S+)",ifconfig.read(),re.S)
|
|
|
|
|
res = re.search(r"(?:HWaddr|ether)\s(\S+)",ifconfig.read(),re.S)
|
|
|
|
|
if res:
|
|
|
|
|
return res.group(1)
|
|
|
|
|
else:
|
|
|
|
@ -149,7 +151,8 @@ def receiveIpAndMask(interface="eth0"):
|
|
|
|
|
"""Get ip and mask from interface"""
|
|
|
|
|
ipconfigProg = checkUtils('/sbin/ifconfig')
|
|
|
|
|
ifconfig = process(ipconfigProg,interface)
|
|
|
|
|
res = re.search(r"inet addr:(\S+)\s.*Mask:(\S+)",ifconfig.read(),re.S)
|
|
|
|
|
res = re.search(r"inet(?: addr:| )(\S+)\s.*(?:Mask:|netmask )(\S+)",
|
|
|
|
|
ifconfig.read(),re.S)
|
|
|
|
|
if res:
|
|
|
|
|
return res.groups()
|
|
|
|
|
else:
|
|
|
|
|