download_fileset.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:nimp 作者: dontnod 项目源码 文件源码
def _make_executable_if_needed(filename):
        # If this is an executable or a script, make it +x
        if MAGIC is not None:
            filetype = MAGIC.from_file(filename)
            if isinstance(filetype, bytes):
                # Older versions of python-magic return bytes instead of a string
                filetype = filetype.decode('ascii')

            if 'executable' in filetype or 'script' in filetype:
                try:
                    logging.info('Making executable because of file type: %s', filetype)
                    file_stat = os.stat(filename)
                    os.chmod(filename, file_stat.st_mode | stat.S_IEXEC)
                except Exception: #pylint: disable=broad-except
                    pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号