예제 #1
0
    def copy(self, dest, skip_if_older=True):
        real_dest = dest
        if not isinstance(dest, basestring):
            fd, dest = mkstemp()
            os.close(fd)
            os.remove(dest)
        assert isinstance(dest, basestring)
        # If File.copy didn't actually copy because dest is newer, check the
        # file sizes. If dest is smaller, it means it is already stripped and
        # elfhacked, so we can skip.
        if not File.copy(self, dest, skip_if_older) and \
                os.path.getsize(self.path) > os.path.getsize(dest):
            return False
        try:
            if may_strip(dest):
                strip(dest)
            if may_elfhack(dest):
                elfhack(dest)
        except ErrorMessage:
            os.remove(dest)
            raise

        if real_dest != dest:
            f = File(dest)
            ret = f.copy(real_dest, skip_if_older)
            os.remove(dest)
            return ret
        return True
예제 #2
0
파일: files.py 프로젝트: imiklos/gecko-dev
    def copy(self, dest, skip_if_older=True):
        real_dest = dest
        if not isinstance(dest, basestring):
            fd, dest = mkstemp()
            os.close(fd)
            os.remove(dest)
        assert isinstance(dest, basestring)
        # If File.copy didn't actually copy because dest is newer, check the
        # file sizes. If dest is smaller, it means it is already stripped and
        # elfhacked, so we can skip.
        if not File.copy(self, dest, skip_if_older) and \
                os.path.getsize(self.path) > os.path.getsize(dest):
            return False
        try:
            if may_strip(dest):
                strip(dest)
            if may_elfhack(dest):
                elfhack(dest)
        except ErrorMessage:
            os.remove(dest)
            raise

        if real_dest != dest:
            f = File(dest)
            ret = f.copy(real_dest, skip_if_older)
            os.remove(dest)
            return ret
        return True
예제 #3
0
 def copy(self, dest):
     assert isinstance(dest, basestring)
     File.copy(self, dest)
     try:
         if may_strip(dest):
             strip(dest)
         if may_elfhack(dest):
             elfhack(dest)
     except ErrorMessage:
         os.remove(dest)
         raise
     return True
예제 #4
0
 def copy(self, dest):
     assert isinstance(dest, basestring)
     tmpfiles = []
     try:
         for p in [self.path1, self.path2]:
             fd, f = mkstemp()
             os.close(fd)
             tmpfiles.append(f)
             shutil.copy2(p, f)
             strip(f)
         subprocess.call(['lipo', '-create'] + tmpfiles + ['-output', dest])
     finally:
         for f in tmpfiles:
             os.unlink(f)