Python os.path.ismount() Examples

The following are code examples for showing how to use os.path.ismount(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: FMICodeGenerator   Author: ghorwin   File: test_plat_other.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def tearDown(self):
        if op.exists(self.file):
            os.remove(self.file)

        trash_file = op.join(HOMETRASH, 'files', self.name)
        if op.exists(trash_file):
            os.remove(trash_file)
            os.remove(op.join(HOMETRASH, 'info', self.name+'.trashinfo'))

#
# Tests for files on some other volume than the user's home directory.
#
# What we need to stub:
# * plat_other.get_dev (to make sure the file will not be on the home dir dev)
# * os.path.ismount (to make our topdir look like a top dir)
# 
Example 2
Project: FMICodeGenerator   Author: ghorwin   File: test_plat_other.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def setUp(self):
        self.trashTopdir = mkdtemp(prefix='s2t')
        if PY3:
            trashTopdir_b = os.fsencode(self.trashTopdir)
        else:
            trashTopdir_b = self.trashTopdir
        self.fileName = 'test.txt'
        self.filePath = op.join(self.trashTopdir, self.fileName)
        touch(self.filePath)

        self.old_ismount = old_ismount = op.ismount
        self.old_getdev = send2trash.plat_other.get_dev
        def s_getdev(path):
            from send2trash.plat_other import is_parent
            st = os.lstat(path)
            if is_parent(self.trashTopdir, path):
                return 'dev'
            return st.st_dev
        def s_ismount(path):
            if op.realpath(path) in (op.realpath(self.trashTopdir), op.realpath(trashTopdir_b)):
                return True
            return old_ismount(path)

        send2trash.plat_other.os.path.ismount = s_ismount
        send2trash.plat_other.get_dev = s_getdev 
Example 3
Project: pipeline   Author: liorbenhorin   File: plat_other.py    MIT License 5 votes vote down vote up
def find_mount_point(path):
    # Even if something's wrong, "/" is a mount point, so the loop will exit.
    # Use realpath in case it's a symlink
    path = op.realpath(path) # Required to avoid infinite loop
    while not op.ismount(path):
        path = op.split(path)[0]
    return path 
Example 4
Project: FMICodeGenerator   Author: ghorwin   File: test_plat_other.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def tearDown(self):
        send2trash.plat_other.get_dev = self.old_getdev
        send2trash.plat_other.os.path.ismount = self.old_ismount
        shutil.rmtree(self.trashTopdir) 
Example 5
Project: FMICodeGenerator   Author: ghorwin   File: plat_other.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def find_mount_point(path):
    # Even if something's wrong, "/" is a mount point, so the loop will exit.
    # Use realpath in case it's a symlink
    path = op.realpath(path) # Required to avoid infinite loop
    while not op.ismount(path):
        path = op.split(path)[0]
    return path 
Example 6
Project: swpy   Author: jongyeob   File: config.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self,filepath='',section=''):
        
        self._config = cp.SafeConfigParser()
        
        if filepath != '':
            filepath = path.abspath(filepath)
            self._filepath = filepath
            
            is_find = False        
            while(is_find == False):
                dirpath,filename = path.split(filepath)
    
                if path.exists(filepath) == False:
                    if path.ismount(dirpath) == True:
                        break
                    filepath = path.normpath(dirpath +'/../'+filename)
                    LOG.debug('searching ini file at %s'%(filepath))
                else:
                    is_find = True
                    self._filepath = filepath
            
            self._config.read(self._filepath)
        
            if is_find == False:
                LOG.info("No log file is found! %s"%(self._filepath))
        
        self.set_section(section) 
Example 7
Project: snpPipeline   Author: kanzwataru   File: plat_other.py    MIT License 5 votes vote down vote up
def find_mount_point(path):
    # Even if something's wrong, "/" is a mount point, so the loop will exit.
    # Use realpath in case it's a symlink
    path = op.realpath(path) # Required to avoid infinite loop
    while not op.ismount(path):
        path = op.split(path)[0]
    return path 
Example 8
Project: PyFlow   Author: wonderworks-software   File: PathLib.py    Apache License 2.0 5 votes vote down vote up
def ismount(path=("StringPin", "", {PinSpecifires.INPUT_WIDGET_VARIANT: "PathWidget"})):
        '''Return True if pathname path is a mount point: a point in a file system where a different file system has been mounted. The function checks whether path’s parent, path/.., is on a different device than path, or whether path/.. and path point to the same i-node on the same device — this should detect mount points for all Unix and POSIX variants.'''
        return osPath.ismount(path) 
Example 9
Project: Snu-Photo-Manager   Author: snuq   File: plat_other.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def find_mount_point(path):
    # Even if something's wrong, "/" is a mount point, so the loop will exit.
    # Use realpath in case it's a symlink
    path = op.realpath(path) # Required to avoid infinite loop
    while not op.ismount(path):
        path = op.split(path)[0]
    return path 
Example 10
Project: AiDevOps   Author: Moniter123   File: files.py    GNU General Public License v2.0 5 votes vote down vote up
def tests(self):
        return {
            # file testing
            'is_dir'  : isdir,
            'is_file' : isfile,
            'is_link' : islink,
            'exists' : exists,
            'link_exists' : lexists,

            # path testing
            'is_abs' : isabs,
            'is_same_file' : samefile,
            'is_mount' : ismount,
        } 
Example 11
Project: FileManager   Author: math2001   File: plat_other.py    MIT License 5 votes vote down vote up
def find_mount_point(path):
    # Even if something's wrong, "/" is a mount point, so the loop will exit.
    # Use realpath in case it's a symlink
    path = op.realpath(path) # Required to avoid infinite loop
    while not op.ismount(path):
        path = op.split(path)[0]
    return path