本文整理汇总了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()
示例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()
示例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()
示例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()
示例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)
示例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()
示例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)