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


Python TempFS.close方法代码示例

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


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

示例1: test_loader_methods

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import close [as 别名]
 def test_loader_methods(self):
     t = TempFS()
     self._init_modules(t)
     ih = FSImportHook(t)
     sys.meta_path.append(ih)
     try:
         self.assertEquals(ih.find_module("fsih_hello"),ih)
         self.assertEquals(ih.find_module("fsih_helo"),None)
         self.assertEquals(ih.find_module("fsih_pkg"),ih)
         self.assertEquals(ih.find_module("fsih_pkg.sub1"),ih)
         self.assertEquals(ih.find_module("fsih_pkg.sub2"),ih)
         self.assertEquals(ih.find_module("fsih_pkg.sub3"),None)
         m = ih.load_module("fsih_hello")
         self.assertEquals(m.message,"hello world!")
         self.assertRaises(ImportError,ih.load_module,"fsih_helo")
         ih.load_module("fsih_pkg")
         m = ih.load_module("fsih_pkg.sub1")
         self.assertEquals(m.message,"hello world!")
         self.assertEquals(m.a,42)
         m = ih.load_module("fsih_pkg.sub2")
         self.assertEquals(m.message,"hello world!")
         self.assertEquals(m.a,42 * 2)
         self.assertRaises(ImportError,ih.load_module,"fsih_pkg.sub3")
     finally:
         sys.meta_path.remove(ih)
         t.close()
开发者ID:anthonybishopric,项目名称:pyboxfs,代码行数:28,代码来源:test_importhook.py

示例2: TestDokan

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import close [as 别名]
    class TestDokan(unittest.TestCase,DokanTestCases,ThreadingTestCases):

        def setUp(self):
            self.temp_fs = TempFS()
            self.drive = "K"
            while os.path.exists(self.drive+":\\") and self.drive <= "Z":
                self.drive = chr(ord(self.drive) + 1)
            if self.drive > "Z":
                raise RuntimeError("no free drive letters")
            fs_to_mount = OSFS(self.temp_fs.getsyspath("/"))
            self.mount_proc = dokan.mount(fs_to_mount,self.drive)#,flags=dokan.DOKAN_OPTION_DEBUG|dokan.DOKAN_OPTION_STDERR,numthreads=1)
            self.fs = OSFS(self.mount_proc.path)

        def tearDown(self):
            self.mount_proc.unmount()
            for _ in xrange(10):
                try:
                    if self.mount_proc.poll() is None:
                        self.mount_proc.terminate()
                except EnvironmentError:
                    time.sleep(0.1)
                else:
                    break
            else:
                if self.mount_proc.poll() is None:
                    self.mount_proc.terminate()
            self.temp_fs.close()
开发者ID:anthonybishopric,项目名称:pyboxfs,代码行数:29,代码来源:test_expose.py

示例3: test_importer_on_meta_path

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import close [as 别名]
 def test_importer_on_meta_path(self):
     t = TempFS()
     self._init_modules(t)
     ih = FSImportHook(t)
     sys.meta_path.append(ih)
     try:
         self._check_imports_are_working()
     finally:
         sys.meta_path.remove(ih)
         t.close()
开发者ID:anthonybishopric,项目名称:pyboxfs,代码行数:12,代码来源:test_importhook.py

示例4: test_url_on_sys_path

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import close [as 别名]
 def test_url_on_sys_path(self):
     t = TempFS()
     zpath = t.getsyspath("modules.zip")
     z = ZipFS(zpath,"w")
     self._init_modules(z)
     z.close()
     z = ZipFS(zpath,"r")
     assert z.isfile("fsih_hello.py")
     z.close()
     sys.path.append("zip://" + zpath)
     FSImportHook.install()
     try:
         self._check_imports_are_working()
     finally:
         sys.path_hooks.remove(FSImportHook)
         sys.path.pop()
         t.close()
开发者ID:anthonybishopric,项目名称:pyboxfs,代码行数:19,代码来源:test_importhook.py

示例5: TestFUSE

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import close [as 别名]
class TestFUSE(unittest.TestCase,FSTestCases):

    def setUp(self):
        self.temp_fs = TempFS()
        self.temp_fs.makedir("root")
        self.temp_fs.makedir("mount")
        self.mounted_fs = self.temp_fs.opendir("root")
        self.mount_point = self.temp_fs.getsyspath("mount")
        self.fs = OSFS(self.temp_fs.getsyspath("mount"))
        self.mount_proc = fuse.mount(self.mounted_fs,self.mount_point)

    def tearDown(self):
        self.mount_proc.unmount()
        self.temp_fs.close()

    def check(self,p):
        return self.mounted_fs.exists(p)
开发者ID:svn2github,项目名称:pyfilesystem,代码行数:19,代码来源:test_expose.py

示例6: snapshot

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import close [as 别名]
    def snapshot(self, path):
        """Takes a snapshot of an individual file."""

        # try grabbing the temp filesystem system path
        temp_dir = None
        temp_dir = self.tmp.getsyspath('/')

        # Create a temp file system to be snapshotted
        temp_snapshot_fs = TempFS(temp_dir=temp_dir)
        src_path = temp_snapshot_fs.getsyspath('/')

        with self.fs.open(path, 'rb') as source_file:
            with temp_snapshot_fs.open('datafile', 'wb') as temp_file:
                shutil.copyfileobj(source_file, temp_file)

        # snapshot destination directory
        dest_dir = self.snapshot_snap_path(path)

        command = ['rdiff-backup',
                   '--parsable-output',
                   '--no-eas',
                   '--no-file-statistics',
                   '--no-acls',
                   '--tempdir', self.tmp.getsyspath('/'),
                   src_path, dest_dir]

        # speed up the tests
        if self.__testing:
            command.insert(5, '--current-time')
            command.insert(6, str(self.__testing['time']))
            self.__testing['time'] += 1

        process = Popen(command, stdout=PIPE, stderr=PIPE)
        stderr = process.communicate()[1]

        ignore = [lambda x: x.startswith("Warning: could not determine case")]

        if len(stderr) is not 0:
            for rule in ignore:
                if not rule(stderr):
                    raise SnapshotError(stderr)

        # close the temp snapshot filesystem
        temp_snapshot_fs.close()
开发者ID:pombreda,项目名称:file-versioning,代码行数:46,代码来源:__init__.py

示例7: TestFUSE

# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import close [as 别名]
    class TestFUSE(unittest.TestCase,FSTestCases,ThreadingTestCases):

        def setUp(self):
            self.temp_fs = TempFS()            
            self.temp_fs.makedir("root")
            self.temp_fs.makedir("mount")
            self.mounted_fs = self.temp_fs.opendir("root")
            self.mount_point = self.temp_fs.getsyspath("mount")
            self.fs = OSFS(self.temp_fs.getsyspath("mount"))
            self.mount_proc = fuse.mount(self.mounted_fs,self.mount_point)

        def tearDown(self):
            self.mount_proc.unmount()
            try:
                self.temp_fs.close()
            except OSError:
                # Sometimes FUSE hangs onto the mountpoint if mount_proc is
                # forcibly killed.  Shell out to fusermount to make sure.
                fuse.unmount(self.mount_point)
                self.temp_fs.close()

        def check(self,p):
            return self.mounted_fs.exists(p)
开发者ID:anthonybishopric,项目名称:pyboxfs,代码行数:25,代码来源:test_expose.py


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