当前位置: 首页>>代码示例>>Python>>正文


Python errno.ENOTDIR属性代码示例

本文整理汇总了Python中errno.ENOTDIR属性的典型用法代码示例。如果您正苦于以下问题:Python errno.ENOTDIR属性的具体用法?Python errno.ENOTDIR怎么用?Python errno.ENOTDIR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在errno的用法示例。


在下文中一共展示了errno.ENOTDIR属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: safe_listdir

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTDIR [as 别名]
def safe_listdir(path):
    """
    Attempt to list contents of path, but suppress some exceptions.
    """
    try:
        return os.listdir(path)
    except (PermissionError, NotADirectoryError):
        pass
    except OSError as e:
        # Ignore the directory if does not exist, not a directory or
        # permission denied
        ignorable = (
            e.errno in (errno.ENOTDIR, errno.EACCES, errno.ENOENT)
            # Python 2 on Windows needs to be handled this way :(
            or getattr(e, "winerror", None) == 267
        )
        if not ignorable:
            raise
    return () 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:21,代码来源:__init__.py

示例2: _get_candidates

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTDIR [as 别名]
def _get_candidates(self, link, package_name):
        can_not_cache = (
            not self.cache_dir or
            not package_name or
            not link
        )
        if can_not_cache:
            return []

        canonical_name = canonicalize_name(package_name)
        formats = index.fmt_ctl_formats(
            self.format_control, canonical_name
        )
        if not self.allowed_formats.intersection(formats):
            return []

        root = self.get_path_for_link(link)
        try:
            return os.listdir(root)
        except OSError as err:
            if err.errno in {errno.ENOENT, errno.ENOTDIR}:
                return []
            raise 
开发者ID:HaoZhang95,项目名称:Python24,代码行数:25,代码来源:cache.py

示例3: list_files

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTDIR [as 别名]
def list_files(self, path):
        p = KubePath().parse_path(path)
        if not p.exists(self.client):
            logger.info("path doesn't exist")
            raise FuseOSError(errno.ENOENT)
        if not p.is_dir():
            logger.info("not a directory")
            raise FuseOSError(errno.ENOTDIR)
        if p.object_id is not None: 
            if p.resource_type != 'pod':
                return p.SUPPORTED_ACTIONS
            else:
                return p.SUPPORTED_POD_ACTIONS
        if p.resource_type is not None:
            return self.client.get_entities(p.namespace, p.resource_type)
        if p.namespace is not None:
            return p.SUPPORTED_RESOURCE_TYPES
        return self.client.get_namespaces()  # + ['all'] 
开发者ID:opencredo,项目名称:kubefuse,代码行数:20,代码来源:filesystem.py

示例4: _get_candidates

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTDIR [as 别名]
def _get_candidates(self, link, package_name):
        # type: (Link, Optional[str]) -> List[Any]
        can_not_cache = (
            not self.cache_dir or
            not package_name or
            not link
        )
        if can_not_cache:
            return []

        canonical_name = canonicalize_name(package_name)
        formats = self.format_control.get_allowed_formats(
            canonical_name
        )
        if not self.allowed_formats.intersection(formats):
            return []

        root = self.get_path_for_link(link)
        try:
            return os.listdir(root)
        except OSError as err:
            if err.errno in {errno.ENOENT, errno.ENOTDIR}:
                return []
            raise 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:26,代码来源:cache.py

示例5: set_directory

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTDIR [as 别名]
def set_directory(self, directory):
        """
        Set the directory where the downloaded file will be placed.

        May raise OSError if the supplied directory path is not suitable.

        @param directory: The directory where the file to be received will be
            placed.
        @type directory: L{bytes}
        """
        if not path.exists(directory):
            raise OSError(errno.ENOENT, "You see no directory there.",
                          directory)
        if not path.isdir(directory):
            raise OSError(errno.ENOTDIR, "You cannot put a file into "
                          "something which is not a directory.",
                          directory)
        if not os.access(directory, os.X_OK | os.W_OK):
            raise OSError(errno.EACCES,
                          "This directory is too hard to write in to.",
                          directory)
        self.destDir = directory 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:irc.py

示例6: errnoToFailure

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTDIR [as 别名]
def errnoToFailure(e, path):
    """
    Map C{OSError} and C{IOError} to standard FTP errors.
    """
    if e == errno.ENOENT:
        return defer.fail(FileNotFoundError(path))
    elif e == errno.EACCES or e == errno.EPERM:
        return defer.fail(PermissionDeniedError(path))
    elif e == errno.ENOTDIR:
        return defer.fail(IsNotADirectoryError(path))
    elif e == errno.EEXIST:
        return defer.fail(FileExistsError(path))
    elif e == errno.EISDIR:
        return defer.fail(IsADirectoryError(path))
    else:
        return defer.fail() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:ftp.py

示例7: is_resource

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTDIR [as 别名]
def is_resource(package, name):
    """True if name is a resource inside package.

    Directories are *not* resources.
    """
    package = _get_package(package)
    _normalize_path(name)
    try:
        package_contents = set(contents(package))
    except OSError as error:
        if error.errno not in (errno.ENOENT, errno.ENOTDIR):
            # We won't hit this in the Python 2 tests, so it'll appear
            # uncovered.  We could mock os.listdir() to return a non-ENOENT or
            # ENOTDIR, but then we'd have to depend on another external
            # library since Python 2 doesn't have unittest.mock.  It's not
            # worth it.
            raise                     # pragma: nocover
        return False
    if name not in package_contents:
        return False
    return (_common.from_package(package) / name).is_file() 
开发者ID:pypa,项目名称:pipenv,代码行数:23,代码来源:_py2.py

示例8: _copy_dir_recursive

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTDIR [as 别名]
def _copy_dir_recursive(src_rel, dst_rel):
        """Copy contents of one directory to another. `dst_rel` dir cannot
        exist. Source: http://stackoverflow.com/a/1994840
        TODO: Move this to file_operations.py module.
        :type src_rel: str
        :param src_rel: Directory to be copied.
        :type dst_rel: str
        :param dst_rel: Directory to be created with contents of ``src_rel``.
        """
        src = os.path.expanduser(src_rel)
        dst = os.path.expanduser(dst_rel)
        try:
            shutil.copytree(src, dst)
            logger.info('Files copied from %s to %s', src, dst)
        except OSError as exc:
            if exc.errno == errno.ENOTDIR:
                shutil.copy(src, dst)
                logger.info('Files copied from %s to %s', src, dst)
            else:
                raise 
开发者ID:cltk,项目名称:cltk,代码行数:22,代码来源:importer.py

示例9: available_bytes_at_path

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTDIR [as 别名]
def available_bytes_at_path(path):
    """Get the available disk space in a given directory.

    Args:
      path (str): Directory path to check.

    Returns:
      int: Available space, in bytes

    Raises:
      OSError: if the specified path does not exist or is not readable.
    """
    if not os.path.exists(path):
        raise OSError(errno.ENOENT, os.strerror(errno.ENOENT), path)
    if not os.path.isdir(path):
        raise OSError(errno.ENOTDIR, os.strerror(errno.ENOTDIR), path)
    available = disk_usage(path).free
    logger.debug("There appears to be %s available at %s",
                 pretty_bytes(available), path)
    return available 
开发者ID:glennmatthews,项目名称:cot,代码行数:22,代码来源:utilities.py

示例10: returns_sftp_error

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOTDIR [as 别名]
def returns_sftp_error(func):

    def wrapped(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except OSError as err:
            LOG.debug("Error calling %s(%s, %s): %s",
                      func, args, kwargs, err, exc_info=True)
            errno = err.errno
            if errno in {EACCES, EDQUOT, EPERM, EROFS}:
                return paramiko.SFTP_PERMISSION_DENIED
            if errno in {ENOENT, ENOTDIR}:
                return paramiko.SFTP_NO_SUCH_FILE
            return paramiko.SFTP_FAILURE
        except Exception as err:
            LOG.debug("Error calling %s(%s, %s): %s",
                      func, args, kwargs, err, exc_info=True)
            return paramiko.SFTP_FAILURE

    return wrapped 
开发者ID:carletes,项目名称:mock-ssh-server,代码行数:22,代码来源:sftp.py


注:本文中的errno.ENOTDIR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。