Move function isFstabMount from calculate-install.

develop
Mike Hiretsky 14 years ago
parent 281de14a47
commit e51a767d92

@ -584,6 +584,28 @@ def getRunCommands():
filter(lambda x:x.isdigit(),
os.listdir('/proc')))
def isFstabMount(pathname):
"""Get mount point or device from fstab"""
if pathname == "swap":
absPath = "swap"
else:
absPath = os.path.abspath(pathname)
# convert fstab to
# [['/dev/sda3', '/', '', 'reiserfs', 'noatime', '', '', '0', '2\n'],
# ['/dev/sda5', '/var/calculate', 'reiserfs', 'noatime', '0', '0\n']]
listFstab = filter(lambda x: len(x) >= 4,
map(lambda x: filter(lambda x: x,
x.replace('\t',' ').split(' ')),
filter(lambda x: not x.startswith('#') and x.strip(),
open("/etc/fstab"))))
# get mount point or device or dir
return filter(lambda x: x!=absPath,
reduce(lambda x,y: y,
filter(lambda x: absPath in x and x[1] != "none",
map(lambda x: [x[0],
x[1] if x[2] != "swap" else "swap"],
listFstab)),[""]))[0]
def isMount(path):
"""В случае монтирования директории выдает другой примонтированный путь"""
absPath = os.path.abspath(path)

Loading…
Cancel
Save