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


Python OSFS.close方法代码示例

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


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

示例1: install_encoded

# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import close [as 别名]
def install_encoded(device_class, version, firmware_b64, activate_firmware=True, firmware_path=None):
    """Install firmware from a b64 encoded zip file"""
    # TODO:  implement this in a less memory hungry way
    # decode from b64
    firmware_bin = base64.b64decode(firmware_b64)
    # Make a file-like object
    firmware_file = BytesIO(firmware_bin)
    # Open zip
    firmware_fs = ZipFS(firmware_file)
    # Open firmware dir
    dst_fs = OSFS(firmware_path or constants.FIRMWARE_PATH, create=True, dir_mode=0o755)
    # Install
    install_path = install(device_class, version, firmware_fs, dst_fs)
    # Move symlink to active firmware
    if activate_firmware:
        activate(device_class, version, dst_fs, fw_path=firmware_path)

    # Clean up any temporary files
    firmware_fs.close()
    dst_fs.close()

    # Return install_path
    return install_path
开发者ID:alextgn63,项目名称:dataplicity,代码行数:25,代码来源:firmware.py

示例2: _decode

# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import close [as 别名]
            if path.lower().startswith("_autorun."):
                path = path[1:]
        return path

    def _decode(self,path):
        path = relpath(normpath(path))
        path = path.replace("__colon__",":")
        if not self.allow_autorun:
            if path.lower().startswith("autorun."):
                path = "_" + path
        return path


if __name__ == "__main__":
    import os, os.path
    import tempfile
    from fs.osfs import OSFS
    from fs.memoryfs import MemoryFS
    path = tempfile.mkdtemp()
    try:
        fs = OSFS(path)
        #fs = MemoryFS()
        fs.setcontents("test1.txt","test one")
        flags = DOKAN_OPTION_DEBUG|DOKAN_OPTION_STDERR|DOKAN_OPTION_REMOVABLE
        mount(fs, "Q", foreground=True, numthreads=1, flags=flags)
        fs.close()
    finally:
        OSFS(path).removedir("/",force=True)


开发者ID:pombreda,项目名称:agilepyfs,代码行数:30,代码来源:__init__.py

示例3: OSFS

# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import close [as 别名]
#!/usr/bin/env python3
import pendulum as pen
import fs
from fs.osfs import OSFS

home = OSFS("c:")
# print(home.listdir("tom"))

directory = list(home.scandir('tom'))
#print(directory)
# for d in directory:
#     print(d)

dir2 = home.filterdir('tom',files=['*.txt'], namespaces=['details'])
for d in dir2:
    # 2016-03-19 13:33:00.656588+00:00
    modified = pen.instance(d.modified).to_datetime_string()
    print(d.name, d.size, modified)


#print(home.tree())


home.close()


开发者ID:okcorral,项目名称:python,代码行数:26,代码来源:filesystem.py


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