Fix detect utils without path. Fix using ifconfig.

develop
Mike Hiretsky 12 years ago
parent cd60886fd8
commit 0ac464c846

@ -934,7 +934,7 @@ def getProgPath(progname):
env = {"LANG":"C"}
env.update(os.environ.items() + [("PATH",getpathenv())] +\
env.items())
res = runOsCommand("which %s"%progname,env_dict=env)
res = runOsCommand("which %s"%baseprogname,env_dict=env)
if res[0] == 0:
return res[1][0].strip()
elif path.isabs(progname) and path.exists(progname):

@ -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:

Loading…
Cancel
Save