當前位置: 首頁>>代碼示例>>Python>>正文


Python AnnexRepo.is_crippled_fs方法代碼示例

本文整理匯總了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())
開發者ID:hanke,項目名稱:datalad,代碼行數:34,代碼來源:test_direct_mode.py

示例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.")
開發者ID:jgors,項目名稱:datalad,代碼行數:11,代碼來源:test_annexrepo.py

示例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)
開發者ID:datalad,項目名稱:datalad,代碼行數:28,代碼來源:test_utils.py

示例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.")
開發者ID:jgors,項目名稱:datalad,代碼行數:13,代碼來源:test_annexrepo.py


注:本文中的datalad.support.annexrepo.AnnexRepo.is_crippled_fs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。