Merge branch 'master' of git.calculate.ru:/calculate-lib

develop
Самоукин Алексей 14 years ago
commit 3f3bfff709

@ -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)
@ -595,6 +617,22 @@ def isMount(path):
map(lambda x: [x[0], x[1]], map(lambda x: x.split(" "),
open(mtabFile)))),[""]))[0]
def childMounts(path):
"""Get all mount points which contain path"""
if path != "none":
absPath = os.path.abspath(path)
else:
absPath = path
mtabFile = '/etc/mtab'
if not os.access(mtabFile,os.R_OK):
return ""
return reduce(lambda x,y: x + [y],
filter(lambda x: absPath in x[0] or absPath in x[1],
map(lambda x: [x[0], x[1]],
map(lambda x: x.split(" "),
open(mtabFile)))),
[])
def pathJoin(*paths):
"""Складывает пути, в отличии от os.path.join, складывает абсолютные пути"""
if len(paths)==1:

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = "2.2.0.0"
__version__ = "2.2.0.1"
__app__ = "calculate-lib"
import sys, os, stat, re

@ -22,7 +22,7 @@ from distutils.core import setup
from distutils.command.build_scripts import build_scripts
from distutils.command.install_scripts import install_scripts
__version__ = "2.2.0.0"
__version__ = "2.2.0.1"
__app__ = "calculate-lib"
class cl_build_scripts(build_scripts):

Loading…
Cancel
Save