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


Python errno.EISDIR属性代码示例

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


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

示例1: from_json

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def from_json(self, filename, silent=False):
        """Updates the values in the config from a JSON file. This function
        behaves as if the JSON object was a dictionary and passed to the
        :meth:`from_mapping` function.

        :param filename: the filename of the JSON file.  This can either be an
                         absolute filename or a filename relative to the
                         root path.
        :param silent: set to ``True`` if you want silent failure for missing
                       files.

        .. versionadded:: 0.11
        """
        filename = os.path.join(self.root_path, filename)

        try:
            with open(filename) as json_file:
                obj = json.loads(json_file.read())
        except IOError as e:
            if silent and e.errno in (errno.ENOENT, errno.EISDIR):
                return False
            e.strerror = 'Unable to load configuration file (%s)' % e.strerror
            raise
        return self.from_mapping(obj) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:config.py

示例2: isTipcAvailable

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def isTipcAvailable():
    """Check if the TIPC module is loaded

    The TIPC module is not loaded automatically on Ubuntu and probably
    other Linux distros.
    """
    if not hasattr(socket, "AF_TIPC"):
        return False
    try:
        f = open("/proc/modules")
    except IOError as e:
        # It's ok if the file does not exist, is a directory or if we
        # have not the permission to read it. In any other case it's a
        # real error, so raise it again.
        if e.errno in (errno.ENOENT, errno.EISDIR, errno.EACCES):
            return False
        else:
            raise
    with f:
        for line in f:
            if line.startswith("tipc "):
                return True
    return False 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_socket.py

示例3: from_json

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def from_json(self, filename, silent=False):
        """Updates the values in the config from a JSON file. This function
        behaves as if the JSON object was a dictionary and passed to the
        :meth:`from_mapping` function.

        :param filename: the filename of the JSON file.  This can either be an
                         absolute filename or a filename relative to the
                         root path.
        :param silent: set to ``True`` if you want silent failure for missing
                       files.

        .. versionadded:: 0.11
        """
        if self.root_path:
            filename = os.path.join(self.root_path, filename)
        try:
            with open(filename) as json_file:
                obj = json.loads(json_file.read())
        except IOError as e:
            if silent and e.errno in (errno.ENOENT, errno.EISDIR):
                return False
            e.strerror = 'Unable to load configuration file (%s)' % e.strerror
            raise
        return self.from_mapping(obj) 
开发者ID:KubeOperator,项目名称:KubeOperator,代码行数:26,代码来源:conf.py

示例4: _ensure_tree

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def _ensure_tree(path):
    """Create a directory (and any ancestor directories required).

    :param path: Directory to create
    """
    try:
        os.makedirs(path)
    except OSError as e:
        if e.errno == errno.EEXIST:
            if not os.path.isdir(path):
                raise
            else:
                return False
        elif e.errno == errno.EISDIR:
            return False
        else:
            raise
    else:
        return True 
开发者ID:harlowja,项目名称:fasteners,代码行数:21,代码来源:process_lock.py

示例5: errnoToFailure

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [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

示例6: openForReading

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def openForReading(self, path):
        """
        Open C{path} for reading.

        @param path: The path, as a list of segments, to open.
        @type path: C{list} of C{unicode}
        @return: A L{Deferred} is returned that will fire with an object
            implementing L{IReadFile} if the file is successfully opened.  If
            C{path} is a directory, or if an exception is raised while trying
            to open the file, the L{Deferred} will fire with an error.
        """
        p = self._path(path)
        if p.isdir():
            # Normally, we would only check for EISDIR in open, but win32
            # returns EACCES in this case, so we check before
            return defer.fail(IsADirectoryError(path))
        try:
            f = p.open('r')
        except (IOError, OSError) as e:
            return errnoToFailure(e.errno, path)
        except:
            return defer.fail()
        else:
            return defer.succeed(_FileReader(f)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:26,代码来源:ftp.py

示例7: openForWriting

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def openForWriting(self, path):
        """
        Open C{path} for writing.

        @param path: The path, as a list of segments, to open.
        @type path: C{list} of C{unicode}
        @return: A L{Deferred} is returned that will fire with an object
            implementing L{IWriteFile} if the file is successfully opened.  If
            C{path} is a directory, or if an exception is raised while trying
            to open the file, the L{Deferred} will fire with an error.
        """
        p = self._path(path)
        if p.isdir():
            # Normally, we would only check for EISDIR in open, but win32
            # returns EACCES in this case, so we check before
            return defer.fail(IsADirectoryError(path))
        try:
            fObj = p.open('w')
        except (IOError, OSError) as e:
            return errnoToFailure(e.errno, path)
        except:
            return defer.fail()
        return defer.succeed(_FileWriter(fObj)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:25,代码来源:ftp.py

示例8: from_file

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def from_file(file_path, silent=False):
    """
    Updates the values in the config from a Python file.  This function
    behaves as if the file was imported as module with the

    :param file_path:
    :param silent:
    """
    d = imp.new_module("config")
    d.__file__ = file_path
    try:
        with open(file_path) as config_file:
            exec(  # nosec: config file safe
                compile(config_file.read(), file_path, "exec"), d.__dict__
            )
    except IOError as e:
        if silent and e.errno in (errno.ENOENT, errno.EISDIR):
            return False
        e.strerror = "Unable to load configuration file (%s)" % e.strerror
        raise
    return d 
开发者ID:Netflix,项目名称:lemur,代码行数:23,代码来源:factory.py

示例9: unlink

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def unlink(self, path):
        if path.parent == path:
            # Short-circuit on failing on root
            raise OSError(errno.EISDIR, os.strerror(errno.EISDIR))

        # NB: dropbox api provides no single-file delete call
        #     if a directory exists at this location, it will recursively
        #     delete everything
        try:
            md = self._clientv2.files_delete(str(path))
        except dropbox.exceptions.ApiError as e:
            if e.error.is_path_lookup():
                raise OSError(errno.ENOENT, os.strerror(errno.ENOENT)) from e
            else:
                raise
        else:
            if isinstance(md, dropbox.files.FolderMetadata):
                log.warn("Called unlink() on directory and it succeeded: %r", path) 
开发者ID:rianhunter,项目名称:dbxfs,代码行数:20,代码来源:dbxfs.py

示例10: _makedirs

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def _makedirs(name):
    dirname = os.path.dirname(name)
    def split_path(lst, path):
        q = os.path.split(path)
        if q[1] != '':
            lst.append(q[1])
            split_path(lst, q[0])

    lst = []
    split_path(lst, dirname)
    lst.reverse()
    mypath = os.path.abspath('/')
    for elem in lst:
        mypath = os.path.join(mypath, elem)
        if not os.path.exists(mypath):
            try:
                os.mkdir(mypath)
            except OSError as e:
                if e.args[0] != errno.EEXIST and e.args[0] != errno.EISDIR:
                    raise 
开发者ID:peterhinch,项目名称:micropython-samples,代码行数:22,代码来源:micropip.py

示例11: sys_ftruncate

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def sys_ftruncate(self, fd, length) -> int:
        """
        Truncate a file to <length>
        :return 0 on success
        """
        try:
            f = self._get_fdlike(fd)
        except FdError as e:
            return -e.err
        except OSError as e:
            return -e.errno
        if isinstance(f, Directory):
            return -errno.EISDIR
        if not isinstance(f, File):
            return -errno.EINVAL
        f.file.truncate(length)
        return 0 
开发者ID:trailofbits,项目名称:manticore,代码行数:19,代码来源:linux.py

示例12: from_pyfile

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def from_pyfile(self, filename, silent=False):
        filename = os.path.join(self.root_path, filename)
        d = types.ModuleType('config')
        d.__file__ = filename
        try:
            with open(filename, mode='rb') as config_file:
                exec(compile(config_file.read(), filename, 'exec'), d.__dict__)
        except IOError as e:
            if silent and e.errno in (
                    errno.ENOENT, errno.EISDIR, errno.ENOTDIR
            ):
                return False
            e.strerror = 'Unable to load configuration file (%s)' % e.strerror
            raise
        self.from_object(d)
        return True 
开发者ID:ctpbee,项目名称:ctpbee,代码行数:18,代码来源:config.py

示例13: openForReading

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def openForReading(self, path):
        """
        Open C{path} for reading.

        @param path: The path, as a list of segments, to open.
        @type path: C{list} of C{unicode}
        @return: A L{Deferred} is returned that will fire with an object
            implementing L{IReadFile} if the file is successfully opened.  If
            C{path} is a directory, or if an exception is raised while trying
            to open the file, the L{Deferred} will fire with an error.
        """
        p = self._path(path)
        if p.isdir():
            # Normally, we would only check for EISDIR in open, but win32
            # returns EACCES in this case, so we check before
            return defer.fail(IsADirectoryError(path))
        try:
            f = p.open('r')
        except (IOError, OSError), e:
            return errnoToFailure(e.errno, path) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:22,代码来源:ftp.py

示例14: __init__

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def __init__(self, ntstatus, filename, filename2=None):
        self.ntstatus = ntstatus
        self.filename2 = to_native(filename2) if filename2 else None

        ntstatus_name = 'STATUS_UNKNOWN'
        for name, val in vars(NtStatus).items():
            if ntstatus == val:
                ntstatus_name = name
                break

        error_details = {
            NtStatus.STATUS_OBJECT_NAME_NOT_FOUND: errno.ENOENT,
            NtStatus.STATUS_OBJECT_PATH_NOT_FOUND: errno.ENOENT,
            NtStatus.STATUS_OBJECT_NAME_COLLISION: errno.EEXIST,
            NtStatus.STATUS_PRIVILEGE_NOT_HELD: (errno.EACCES, "Required privilege not held"),
            NtStatus.STATUS_SHARING_VIOLATION: (errno.EPERM, "The process cannot access the file because it is being "
                                                             "used by another process"),
            NtStatus.STATUS_NOT_A_REPARSE_POINT: (errno.EINVAL, "The file or directory is not a reparse point"),
            NtStatus.STATUS_FILE_IS_A_DIRECTORY: errno.EISDIR,
            NtStatus.STATUS_NOT_A_DIRECTORY: errno.ENOTDIR,
            NtStatus.STATUS_DIRECTORY_NOT_EMPTY: errno.ENOTEMPTY,
            NtStatus.STATUS_END_OF_FILE: getattr(errno, 'ENODATA', 120),  # Not present on py2 for Windows.
        }.get(ntstatus, (0, "Unknown NtStatus error returned '%s'" % ntstatus_name))

        if not isinstance(error_details, tuple):
            error_details = (error_details, os.strerror(error_details))

        super(SMBOSError, self).__init__(error_details[0], error_details[1], to_native(filename)) 
开发者ID:jborean93,项目名称:smbprotocol,代码行数:30,代码来源:exceptions.py

示例15: get_io_os_error_sugg

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EISDIR [as 别名]
def get_io_os_error_sugg(value, frame, groups):
    """Get suggestions for IOError/OSError exception."""
    # https://www.python.org/dev/peps/pep-3151/
    del frame, groups  # unused param
    err, _ = value.args
    errnos = {
        errno.ENOENT: suggest_if_file_does_not_exist,
        errno.ENOTDIR: suggest_if_file_is_not_dir,
        errno.EISDIR: suggest_if_file_is_dir,
    }
    return errnos.get(err, lambda x: [])(value) 
开发者ID:SylvainDe,项目名称:DidYouMean-Python,代码行数:13,代码来源:didyoumean_internal.py


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