本文整理汇总了Python中fs.tempfs.TempFS.getsyspath方法的典型用法代码示例。如果您正苦于以下问题:Python TempFS.getsyspath方法的具体用法?Python TempFS.getsyspath怎么用?Python TempFS.getsyspath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs.tempfs.TempFS
的用法示例。
在下文中一共展示了TempFS.getsyspath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDokan
# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import getsyspath [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()
示例2: TestFUSE
# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import getsyspath [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)
示例3: TestFUSE
# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import getsyspath [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)
示例4: test_url_on_sys_path
# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import getsyspath [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: snapshot
# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import getsyspath [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()
示例6: setUp
# 需要导入模块: from fs.tempfs import TempFS [as 别名]
# 或者: from fs.tempfs.TempFS import getsyspath [as 别名]
def setUp(self):
rootfs = TempFS()
backup = TempFS(temp_dir=rootfs.getsyspath('/'))
self.fs = VersioningFS(rootfs, backup=backup, tmp=TempFS())