Add check file existing for functions.

Check added for function isMount and getRunCommands.
develop
Mike Hiretsky 14 years ago
parent 0240ec5b1c
commit cee0c6fa58

@ -516,6 +516,8 @@ def removeDir(rmDir):
def getRunCommands():
"""List run program"""
if not os.access('/proc',os.R_OK):
return []
return map(lambda x:open('/proc/%s/cmdline'%x).read().strip(),
filter(lambda x:x.isdigit(),
os.listdir('/proc')))
@ -523,10 +525,13 @@ def getRunCommands():
def isMount(path):
"""В случае монтирования директории выдает другой примонтированный путь"""
absPath = os.path.abspath(path)
mtabFile = '/etc/mtab'
if not os.access(mtabFile,os.R_OK):
return ""
return filter(lambda x: x!=absPath,
reduce(lambda x,y: y, filter(lambda x: absPath in x,
map(lambda x: [x[0], x[1]], map(lambda x: x.split(" "),
open("/etc/mtab")))),[""]))[0]
open(mtabFile)))),[""]))[0]
def pathJoin(*paths):
"""Складывает пути, в отличии от os.path.join, складывает абсолютные пути"""

Loading…
Cancel
Save