Beispiel #1
0
    def _test_archive(self, archivename, type_):
        from applib import sh
        from serverzen_fabric.archive import Archive
        import os

        name1 = 'hellworld.txt'
        text1 = 'random text'
        fname = self.newfile(name1, text1)
        tempdir1 = self.mkdtemp('tempdir1-' + archivename)
        tarball = os.path.join(tempdir1, archivename)
        sh.pack_archive(tarball,
                        [fname],
                        os.path.dirname(fname),
                        type_)

        tempdir2 = self.mkdtemp('tempdir2-' + archivename)
        arc = Archive(tarball)
        arc.extractall(tempdir2, run_local=True)
        self.assertTrue(name1 in os.listdir(tempdir2),
                        'File not extracted properly')
        self.assertEqual(text1,
                         open(os.path.join(tempdir2, name1)).read())
Beispiel #2
0
 def pack_contents(fn, parentdir):
     """Pack the contents of directory ``parentdir`` into ``fn``"""
     sh.pack_archive(
         fn, [xjoin(parentdir, f) for f in os.listdir(parentdir)],
         parentdir)
Beispiel #3
0
 def pack_contents(fn, parentdir):
     sh.pack_archive(
         fn,
         [xjoin(parentdir, f) for f in os.listdir(parentdir)],
         parentdir)
Beispiel #4
0
 def pack_contents(fn, parentdir):
     """Pack the contents of directory ``parentdir`` into ``fn``"""
     sh.pack_archive(
         fn,
         [xjoin(parentdir, f) for f in os.listdir(parentdir)],
         parentdir)