本文整理汇总了Python中datalad.support.annexrepo.AnnexRepo.is_crippled_fs方法的典型用法代码示例。如果您正苦于以下问题:Python AnnexRepo.is_crippled_fs方法的具体用法?Python AnnexRepo.is_crippled_fs怎么用?Python AnnexRepo.is_crippled_fs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datalad.support.annexrepo.AnnexRepo
的用法示例。
在下文中一共展示了AnnexRepo.is_crippled_fs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_direct_cfg
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import is_crippled_fs [as 别名]
def test_direct_cfg(path1, path2, path3, path4):
with patch.dict('os.environ', {'DATALAD_REPO_DIRECT': 'True'}):
# create annex repo in direct mode:
with swallow_logs(new_level=logging.DEBUG) as cml:
ar = AnnexRepo(path1, create=True)
cml.assert_logged("Switching to direct mode",
regex=False, level='DEBUG')
ok_(ar.is_direct_mode())
# but don't if repo version is 6 (actually, 6 or above):
with swallow_logs(new_level=logging.WARNING) as cml:
ar = AnnexRepo(path2, create=True, version=6)
ok_(not ar.is_direct_mode())
cml.assert_logged("direct mode not available", regex=False,
level='WARNING')
# explicit parameter `direct` has priority:
ar = AnnexRepo(path3, create=True, direct=False)
if not ar.is_crippled_fs(): # otherwise forced direct mode
ok_(not ar.is_direct_mode())
# don't touch existing repo:
ar = AnnexRepo(path2, create=True)
if not ar.is_crippled_fs(): # otherwise forced direct mode
ok_(not ar.is_direct_mode())
# make sure, value is relevant:
with patch.dict('os.environ', {'DATALAD_REPO_DIRECT': '0'}):
# don't use direct mode
ar = AnnexRepo(path4, create=True)
if not ar.is_crippled_fs(): # otherwise forced direct mode
ok_(not ar.is_direct_mode())
示例2: test_AnnexRepo_crippled_filesystem
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import is_crippled_fs [as 别名]
def test_AnnexRepo_crippled_filesystem(src, dst):
# TODO: This test is rudimentary, since platform not really determines filesystem.
# For now this should work for the buildbots. Nevertheless: Find a better way to test it.
ar = AnnexRepo(dst, src)
if on_windows:
assert_true(ar.is_crippled_fs(), "Detected non-crippled filesystem on windows.")
else:
assert_false(ar.is_crippled_fs(), "Detected crippled filesystem on non-windows.")
示例3: test_rotree
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import is_crippled_fs [as 别名]
def test_rotree(d):
d2 = opj(d, 'd1', 'd2') # deep nested directory
f = opj(d2, 'f1')
os.makedirs(d2)
with open(f, 'w') as f_:
f_.write("LOAD")
with swallow_logs():
ar = AnnexRepo(d2)
rotree(d)
# we shouldn't be able to delete anything UNLESS in "crippled" situation:
# root, or filesystem is FAT etc
# Theoretically annex should declare FS as crippled when ran as root, but
# see http://git-annex.branchable.com/bugs/decides_that_FS_is_crippled_
# under_cowbuilder___40__symlinks_supported_etc__41__/#comment-60c3cbe2710d6865fb9b7d6e247cd7aa
# so explicit 'or'
if not (ar.is_crippled_fs() or (os.getuid() == 0)):
assert_raises(OSError, os.unlink, f) # OK to use os.unlink
assert_raises(OSError, unlink, f) # and even with waiting and trying!
assert_raises(OSError, shutil.rmtree, d)
# but file should still be accessible
with open(f) as f_:
eq_(f_.read(), "LOAD")
# make it RW
rotree(d, False)
unlink(f)
shutil.rmtree(d)
示例4: test_AnnexRepo_set_direct_mode
# 需要导入模块: from datalad.support.annexrepo import AnnexRepo [as 别名]
# 或者: from datalad.support.annexrepo.AnnexRepo import is_crippled_fs [as 别名]
def test_AnnexRepo_set_direct_mode(src, dst):
ar = AnnexRepo(dst, src)
ar.set_direct_mode(True)
assert_true(ar.is_direct_mode(), "Switching to direct mode failed.")
if ar.is_crippled_fs():
assert_raises(CommandNotAvailableError, ar.set_direct_mode, False)
assert_true(ar.is_direct_mode(), "Indirect mode on crippled fs detected. Shouldn't be possible.")
else:
ar.set_direct_mode(False)
assert_false(ar.is_direct_mode(), "Switching to indirect mode failed.")