Пример #1
0
 def compressDiskImage(self, vmdkPath):
     if not self.WithCompressedDisks:
         # Need to add the file to the final directory
         destf = util.AtomicFile(os.path.join(self.outputDir, self.basefilename + '.vmdk'))
         util.copyfileobj(file(vmdkPath), destf)
         destf.commit()
         return destf.finalPath
     vmdkGzOutputFile = os.path.join(self.outputDir, self.basefilename +
             '.vmdk.gz')
     self.gzip(vmdkPath, vmdkGzOutputFile)
     util.remove(vmdkPath)
     return vmdkGzOutputFile
Пример #2
0
 def testRemove(self):
     # test removing a file while keeping the subdir
     d = tempfile.mkdtemp()
     fn = os.sep.join((d, 'hello'))
     f = open(fn, 'w')
     f.write('hello')
     subdir = os.sep.join((d, 'subdir'))
     os.mkdir(subdir)
     self.logFilter.add()
     util.remove(os.sep.join((d, '*')))
     self.logFilter.remove()
     self.logFilter.compare(('warning: Not removing directory %s' %subdir))
     assert(not os.path.exists(fn) and os.path.isdir(subdir))
     util.rmtree(d)
Пример #3
0
 def do(self):
     dir = self.macros['infodir']+'/dir'
     fsdir = self.macros['destdir']+dir
     if os.path.exists(fsdir):
         if not self.policyException(dir):
             util.remove(fsdir)
     if os.path.isdir('%(destdir)s/%(infodir)s' %self.macros):
         infofilespath = '%(destdir)s/%(infodir)s' %self.macros
         infofiles = os.listdir(infofilespath)
         for file in infofiles:
             self._moveToInfoRoot(file)
         infofiles = os.listdir(infofilespath)
         for file in infofiles:
             self._processInfoFile(file)
Пример #4
0
 def testRemove(self):
     # test removing a file while keeping the subdir
     d = tempfile.mkdtemp()
     fn = os.sep.join((d, 'hello'))
     f = open(fn, 'w')
     f.write('hello')
     subdir = os.sep.join((d, 'subdir'))
     os.mkdir(subdir)
     self.logFilter.add()
     util.remove(os.sep.join((d, '*')))
     self.logFilter.remove()
     self.logFilter.compare(('warning: Not removing directory %s' %subdir))
     assert(not os.path.exists(fn) and os.path.isdir(subdir))
     util.rmtree(d)
Пример #5
0
    def doFile(self, path):
        fullpath = self.macros.destdir + path
        if os.path.islink(fullpath):
            return

        fileName = os.path.basename(path)
        if fileName in self.builddirfiles:
            dirName = self.findRightFile(fullpath, fileName,
                                         self.builddirfiles[fileName])
            if dirName is None:
                return

            # if destdir file eq to symlink in builddir
            if os.path.islink(self.macros.builddir + dirName + os.sep +
                              fileName):
                return

            testpath = ('%(destdir)s%(thistestdir)s' + os.sep + dirName +
                        os.sep + fileName) % self.macros
            util.mkdirChain(os.path.dirname(testpath))

            if os.path.islink(testpath):
                buildpath = ''.join(
                    (self.macros.builddir, dirName, os.sep, fileName))
                if self.betterLink(self.macros.destdir + path, testpath,
                                   buildpath):
                    util.remove(testpath)
                    os.symlink(util.normpath(path), testpath)
                else:
                    return
            else:
                os.symlink(util.normpath(path), testpath)

            # we've added a builddir file to the testdir,
            # see if there was a symlink in the builddir
            # that pointed to it
            builddirFile = os.path.join(dirName, fileName)
            if builddirFile in self.builddirlinks:
                for path in self.builddirlinks[builddirFile]:
                    linkpath = '%(destdir)s%(thistestdir)s' % self.macros + os.sep + path
                    if not os.path.islink(linkpath):
                        util.mkdirChain(os.path.dirname(linkpath))
                        os.symlink(
                            '%(thistestdir)s/' % self.macros + dirName +
                            os.sep + fileName, linkpath)
Пример #6
0
    def do(self):
        e = '%(destdir)s/%(sysconfdir)s/X11/app-defaults' % self.macros
        if not os.path.isdir(e):
            return

        x = '%(destdir)s/%(x11prefix)s/lib/X11/app-defaults' % self.macros
        self.warn('app-default files misplaced in'
                  ' %(sysconfdir)s/X11/app-defaults' % self.macros)
        if os.path.islink(x):
            util.remove(x)
        util.mkdirChain(x)
        for file in os.listdir(e):
            util.rename(util.joinPaths(e, file),
                        util.joinPaths(x, file))
            try:
                self.recipe.recordMove(util.joinPaths(e, file),
                        util.joinPaths(x, file))
            except AttributeError:
                pass
Пример #7
0
    def doFile(self, path):
        fullpath = self.macros.destdir + path
        if os.path.islink(fullpath):
            return

        fileName = os.path.basename(path)
        if fileName in self.builddirfiles:
            dirName = self.findRightFile(fullpath, fileName,
                         self.builddirfiles[fileName])
            if dirName is None:
                return

            # if destdir file eq to symlink in builddir
            if os.path.islink(self.macros.builddir + dirName + os.sep
                               + fileName):
                return

            testpath = ('%(destdir)s%(thistestdir)s' + os.sep + dirName
                         + os.sep + fileName) % self.macros
            util.mkdirChain(os.path.dirname(testpath))

            if os.path.islink(testpath):
                buildpath = ''.join((self.macros.builddir, dirName, os.sep, fileName))
                if self.betterLink(self.macros.destdir + path, testpath, buildpath):
                    util.remove(testpath)
                    os.symlink(util.normpath(path), testpath)
                else:
                    return
            else:
                os.symlink(util.normpath(path), testpath)

            # we've added a builddir file to the testdir,
            # see if there was a symlink in the builddir
            # that pointed to it
            builddirFile = os.path.join(dirName, fileName)
            if builddirFile in self.builddirlinks:
                for path in self.builddirlinks[builddirFile]:
                    linkpath = '%(destdir)s%(thistestdir)s' % self.macros + os.sep + path
                    if not os.path.islink(linkpath):
                        util.mkdirChain(os.path.dirname(linkpath))
                        os.symlink('%(thistestdir)s/' % self.macros + dirName
                                    + os.sep + fileName, linkpath)
Пример #8
0
 def testRemoveSymlinkToDir(self):
     # test removing a symlink to a dir -- it should not follow symlink
     # even when recursive = True
     d = tempfile.mkdtemp()
     fn = os.sep.join((d, 'hello'))
     f = open(fn, 'w')
     f.write('hello')
     subdir = os.sep.join((d, 'subdir'))
     os.mkdir(subdir)
     subdir2 = os.sep.join((d, 'subdir2'))
     os.mkdir(subdir2)
     os.symlink(subdir, subdir2 + '/symlink')
     util.rmtree(subdir2 + '/*')
     assert(os.path.exists(subdir))
     assert(os.path.exists(subdir2))
     assert(not os.path.exists(subdir2 + '/symlink'))
     os.symlink(subdir, subdir2 + '/symlink')
     util.remove(subdir2 + '/*')
     assert(os.path.exists(subdir))
     assert(os.path.exists(subdir2))
     assert(not os.path.exists(subdir2 + '/symlink'))
     util.rmtree(d)
Пример #9
0
 def testRemoveSymlinkToDir(self):
     # test removing a symlink to a dir -- it should not follow symlink
     # even when recursive = True
     d = tempfile.mkdtemp()
     fn = os.sep.join((d, 'hello'))
     f = open(fn, 'w')
     f.write('hello')
     subdir = os.sep.join((d, 'subdir'))
     os.mkdir(subdir)
     subdir2 = os.sep.join((d, 'subdir2'))
     os.mkdir(subdir2)
     os.symlink(subdir, subdir2 + '/symlink')
     util.rmtree(subdir2 + '/*')
     assert(os.path.exists(subdir))
     assert(os.path.exists(subdir2))
     assert(not os.path.exists(subdir2 + '/symlink'))
     os.symlink(subdir, subdir2 + '/symlink')
     util.remove(subdir2 + '/*')
     assert(os.path.exists(subdir))
     assert(os.path.exists(subdir2))
     assert(not os.path.exists(subdir2 + '/symlink'))
     util.rmtree(d)
Пример #10
0
    def tearDown(self):
        util.remove(self.sampleFile)

        jobslave_helper.JobSlaveHelper.tearDown(self)
Пример #11
0
 def doFile(self, path):
     if hasattr(self.recipe, '_getCapsulePathsForFile'):
         if self.recipe._getCapsulePathsForFile(path):
             return
     self.info("Removing %s", path)
     util.remove(self.macros['destdir'] + path, quiet=True)
Пример #12
0
 def doFile(self, path):
     if hasattr(self.recipe, '_getCapsulePathsForFile'):
         if self.recipe._getCapsulePathsForFile(path):
             return
     self.info("Removing %s", path)
     util.remove(self.macros['destdir']+path, quiet=True)
Пример #13
0
 def destroy(self):
     if self.image:
         util.remove(self.image)
         self.image = None