python类S_IREAD的实例源码

__init__.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:my-first-blog 作者: AnkurBegining 项目源码 文件源码 阅读 13 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
device.py 文件源码 项目:core-framework 作者: RedhawkSDR 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def execute(self, name, options, parameters):
        try:
            self._cmdLock.acquire()
            self._log.debug("execute(%s, %s, %s)", name, options, parameters)
            if not name.startswith("/"):
                raise CF.InvalidFileName(CF.CF_EINVAL, "Filename must be absolute")

            if self.isLocked(): raise CF.Device.InvalidState("System is locked down")
            if self.isDisabled(): raise CF.Device.InvalidState("System is disabled")

            priority = 0
            stack_size = 4096
            invalidOptions = []
            for option in options:
                val = option.value.value()
                if option.id == CF.ExecutableDevice.PRIORITY_ID:
                    if ((not isinstance(val, int)) and (not isinstance(val, long))):
                        invalidOptions.append(option)
                    else:
                        priority = val
                elif option.id == CF.ExecutableDevice.STACK_SIZE_ID:
                    if ((not isinstance(val, int)) and (not isinstance(val, long))):
                        invalidOptions.append(option)
                    else:
                        stack_size = val
            if len(invalidOptions) > 0:
                self._log.error("execute() received invalid options %s", invalidOptions)
                raise CF.ExecutableDevice.InvalidOptions(invalidOptions)

            command = name[1:] # This is relative to our CWD
            self._log.debug("Running %s %s", command, os.getcwd())

            if not os.path.isfile(command):
                raise CF.InvalidFileName(CF.CF_EINVAL, "File could not be found %s" % command)
            os.chmod(command, os.stat(command)[0] | stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
        finally:
            self._cmdLock.release()

        return self._execute(command, options, parameters)
misc.py 文件源码 项目:pip-update-requirements 作者: alanhamlett 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:swjtu-pyscraper 作者: Desgard 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:noc-orchestrator 作者: DirceuSilvaLabs 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:noc-orchestrator 作者: DirceuSilvaLabs 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:noc-orchestrator 作者: DirceuSilvaLabs 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:noc-orchestrator 作者: DirceuSilvaLabs 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:jira_worklog_scanner 作者: pgarneau 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
path.py 文件源码 项目:zoocore 作者: dsparrow27 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def getReadable(self):
        """
        returns whether the current instance's file is readable or not.  if the file
        doesn't exist False is returned
        """
        try:
            s = os.stat(self)
            return s.st_mode & stat.S_IREAD
        except:
            # i think this only happens if the file doesn't exist
            return False
path.py 文件源码 项目:zoocore 作者: dsparrow27 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def setWritable(self, state=True):
        """
        sets the writeable flag (ie: !readonly)
        """
        try:
            setTo = stat.S_IREAD
            if state:
                setTo = stat.S_IWRITE

            os.chmod(self, setTo)
        except:
            pass
__init__.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
_utils.py 文件源码 项目:SDK 作者: Keypirinha 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def file_set_readonly(path, enable, follow_symlinks=True, recursive=False):
    """Apply or remove the read-only property of a given file or directory."""
    st_mode = os.stat(path, follow_symlinks=follow_symlinks).st_mode
    new_attr = (
        (st_mode | stat.S_IREAD) & ~stat.S_IWRITE if enable
        else (st_mode | stat.S_IWRITE) & ~stat.S_IREAD)
    if new_attr != st_mode:
        os.chmod(path, new_attr)

    if recursive and stat.S_ISDIR(st_mode):
        for entry in os.scandir(path):
            file_set_readonly(entry.path, enable, follow_symlinks, recursive)
__init__.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:ascii-art-py 作者: blinglnav 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:ivaochdoc 作者: ivaoch 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise
__init__.py 文件源码 项目:aws-cfn-plex 作者: lordmuffin 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def rmtree_errorhandler(func, path, exc_info):
    """On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems."""
    # if file type currently read only
    if os.stat(path).st_mode & stat.S_IREAD:
        # convert to read/write
        os.chmod(path, stat.S_IWRITE)
        # use the original function to repeat the operation
        func(path)
        return
    else:
        raise


问题


面经


文章

微信
公众号

扫码关注公众号