Beispiel #1
0
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)
Beispiel #2
0
 def setup_cache(self):
     ds_path = create_test_dataset(self.dsname, spec='2/-2/-2', seed=0)[0]
     self.log("Setup cache ds path %s. CWD: %s", ds_path, getpwd())
     # Will store into a tarfile since otherwise install -r is way too slow
     # to be invoked for every benchmark
     # Store full path since apparently setup is not ran in that directory
     self.tarfile = op.realpath(SampleSuperDatasetBenchmarks.tarfile)
     with tarfile.open(self.tarfile, "w") as tar:
         # F.CK -- Python tarfile can't later extract those because key dirs are
         # read-only.  For now just a workaround - make it all writeable
         from datalad.utils import rotree
         rotree(self.dsname, ro=False, chmod_files=False)
         tar.add(self.dsname, recursive=True)
     rmtree(self.dsname)
Beispiel #3
0
    def setup_cache(self):
        # creating in CWD so things get removed when ASV is done
        ds_path = create_test_dataset("testds1", spec='2/-2/-2', seed=0)[0]
        # Will store into a tarfile since otherwise install -r is way too slow
        # to be invoked for every benchmark
        tarfile_path = opj(osp.dirname(ds_path), 'testds1.tar')
        with tarfile.open(tarfile_path, "w") as tar:
            # F.CK -- Python tarfile can't later extract those because key dirs are
            # read-only.  For now just a workaround - make it all writeable
            from datalad.utils import rotree
            rotree('testds1', ro=False, chmod_files=False)
            tar.add('testds1', recursive=True)
        rmtree('testds1')

        return tarfile_path
Beispiel #4
0
    def setup_cache(self):
        # creating in CWD so things get removed when ASV is done
        ds_path = create_test_dataset("testds1", spec='2/-2/-2', seed=0)[0]
        # Will store into a tarfile since otherwise install -r is way too slow
        # to be invoked for every benchmark
        tarfile_path = opj(osp.dirname(ds_path), 'testds1.tar')
        with tarfile.open(tarfile_path, "w") as tar:
            # F.CK -- Python tarfile can't later extract those because key dirs are
            # read-only.  For now just a workaround - make it all writeable
            from datalad.utils import rotree
            rotree('testds1', ro=False, chmod_files=False)
            tar.add('testds1', recursive=True)
        rmtree('testds1')

        return tarfile_path
Beispiel #5
0
 def setup_cache(self):
     ds_path = create_test_dataset(
         self.dsname
         , spec='2/-2/-2'
         , seed=0
     )[0]
     self.log("Setup cache ds path %s. CWD: %s", ds_path, getpwd())
     # Will store into a tarfile since otherwise install -r is way too slow
     # to be invoked for every benchmark
     # Store full path since apparently setup is not ran in that directory
     self.tarfile = op.realpath(SampleSuperDatasetBenchmarks.tarfile)
     with tarfile.open(self.tarfile, "w") as tar:
         # F.CK -- Python tarfile can't later extract those because key dirs are
         # read-only.  For now just a workaround - make it all writeable
         from datalad.utils import rotree
         rotree(self.dsname, ro=False, chmod_files=False)
         tar.add(self.dsname, recursive=True)
     rmtree(self.dsname)