python类S_ISBLK的实例源码

utils.py 文件源码 项目:bob 作者: BobBuildTool 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __hashEntry(self, prefix, entry, s):
        if stat.S_ISREG(s.st_mode):
            digest = self.__index.check(prefix, entry, s, hashFile)
        elif stat.S_ISDIR(s.st_mode):
            digest = self.__hashDir(prefix, entry)
        elif stat.S_ISLNK(s.st_mode):
            digest = self.__index.check(prefix, entry, s, DirHasher.__hashLink)
        elif stat.S_ISBLK(s.st_mode) or stat.S_ISCHR(s.st_mode):
            digest = struct.pack("<L", s.st_rdev)
        elif stat.S_ISFIFO(s.st_mode):
            digest = b''
        else:
            digest = b''
            logging.getLogger(__name__).warning("Unknown file: %s", entry)

        return digest
osd.py 文件源码 项目:python-ceph-cfg 作者: oms4suse 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def is_partition(self, dev):
        """
        Check whether a given device path is a partition or a full disk.
        """
        if not os.path.exists(dev):
            raise Error('device not found', dev)

        dev = os.path.realpath(dev)
        if not stat.S_ISBLK(os.lstat(dev).st_mode):
            raise Error('not a block device', dev)

        name = self._get_dev_name(dev)
        if os.path.exists(os.path.join('/sys/block', name)):
            return False

        # make sure it is a partition of something else
        for basename in os.listdir('/sys/block'):
            if os.path.exists(os.path.join('/sys/block', basename, name)):
                return True
        raise Error('not a disk or partition', dev)
filegenerator.py 文件源码 项目:AshsSDK 作者: thehappydinoa 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def is_special_file(path):
    """
    This function checks to see if a special file.  It checks if the
    file is a character special device, block special device, FIFO, or
    socket. 
    """
    mode = os.stat(path).st_mode
    # Character special device.
    if stat.S_ISCHR(mode):
        return True
    # Block special device
    if stat.S_ISBLK(mode):
        return True
    # FIFO.
    if stat.S_ISFIFO(mode):
        return True
    # Socket.
    if stat.S_ISSOCK(mode):
        return True
    return False
tools.py 文件源码 项目:hachoir3 作者: vstinner 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _ftypelet(mode):
    if stat.S_ISREG(mode) or not stat.S_IFMT(mode):
        return '-'
    if stat.S_ISBLK(mode):
        return 'b'
    if stat.S_ISCHR(mode):
        return 'c'
    if stat.S_ISDIR(mode):
        return 'd'
    if stat.S_ISFIFO(mode):
        return 'p'
    if stat.S_ISLNK(mode):
        return 'l'
    if stat.S_ISSOCK(mode):
        return 's'
    return '?'
utils.py 文件源码 项目:charm-plumgrid-gateway 作者: openstack 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-swift-proxy 作者: openstack 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-swift-proxy 作者: openstack 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-heat 作者: openstack 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-keystone 作者: openstack 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-keystone 作者: openstack 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-keystone 作者: openstack 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-keystone 作者: openstack 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-nova-cloud-controller 作者: openstack 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-nova-compute 作者: openstack 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-nova-compute 作者: openstack 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:aws-cfn-plex 作者: lordmuffin 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def is_special_file(cls, filename):
        """Checks to see if a file is a special UNIX file.

        It checks if the file is a character special device, block special
        device, FIFO, or socket.

        :param filename: Name of the file

        :returns: True if the file is a special file. False, if is not.
        """
        # If it does not exist, it must be a new file so it cannot be
        # a special file.
        if not os.path.exists(filename):
            return False
        mode = os.stat(filename).st_mode
        # Character special device.
        if stat.S_ISCHR(mode):
            return True
        # Block special device
        if stat.S_ISBLK(mode):
            return True
        # Named pipe / FIFO
        if stat.S_ISFIFO(mode):
            return True
        # Socket.
        if stat.S_ISSOCK(mode):
            return True
        return False
rpm.py 文件源码 项目:crypto-detector 作者: Wind-River 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def isblk(self):
        return stat.S_ISBLK(self.mode)
rpm.py 文件源码 项目:crypto-detector 作者: Wind-River 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def isdev(self):
        return (stat.S_ISCHR(self.mode) or stat.S_ISBLK(self.mode))
# class CpioInfo
utils.py 文件源码 项目:charm-ceph-osd 作者: openstack 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:AshsSDK 作者: thehappydinoa 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def is_special_file(cls, filename):
        """Checks to see if a file is a special UNIX file.

        It checks if the file is a character special device, block special
        device, FIFO, or socket.

        :param filename: Name of the file

        :returns: True if the file is a special file. False, if is not.
        """
        # If it does not exist, it must be a new file so it cannot be
        # a special file.
        if not os.path.exists(filename):
            return False
        mode = os.stat(filename).st_mode
        # Character special device.
        if stat.S_ISCHR(mode):
            return True
        # Block special device
        if stat.S_ISBLK(mode):
            return True
        # Named pipe / FIFO
        if stat.S_ISFIFO(mode):
            return True
        # Socket.
        if stat.S_ISSOCK(mode):
            return True
        return False
utils.py 文件源码 项目:charm-glance 作者: openstack 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    return S_ISBLK(stat(path).st_mode)
utils.py 文件源码 项目:charm-glance 作者: openstack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    return S_ISBLK(stat(path).st_mode)
utils.py 文件源码 项目:charm-glance 作者: openstack 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    return S_ISBLK(stat(path).st_mode)
utils.py 文件源码 项目:charm-glance 作者: openstack 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    return S_ISBLK(stat(path).st_mode)
utils.py 文件源码 项目:charm-neutron-api 作者: openstack 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-ceph-mon 作者: openstack 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-openstack-dashboard 作者: openstack 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-ceilometer 作者: openstack 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-ceilometer 作者: openstack 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)
utils.py 文件源码 项目:charm-ceilometer 作者: openstack 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def is_block_device(path):
    '''
    Confirm device at path is a valid block device node.

    :returns: boolean: True if path is a block device, False if not.
    '''
    if not os.path.exists(path):
        return False
    return S_ISBLK(os.stat(path).st_mode)


问题


面经


文章

微信
公众号

扫码关注公众号