Ejemplo n.º 1
0
 def extractFromFileAndCrc(self, crc, dest):
     if not gotLib7z:
         writeError("Sorry, You cannot use 7z file")
         return False
     writeInfo("Extract 7Z file")
     fp = open(self.file, 'rb')
     archive = Archive7z(fp)
     for name in archive.getnames():
         fd = archive.getmember(name)
         crcFd = getCRCFromBuffer(fd.read())
         if crc == crcFd:
             writeInfo("On extracte un 7z %s" % file)
             fd.reset()
             data = fd.read()
             nameDest = os.path.basename(name)
             writeInfo("On extract du 7z " + nameDest)
             fdest = NamedTemporaryFile()
             #fdest = open("tmp" + "/" + nameDest, 'w+b', os.O_SYNC)
             fdest.write(data)
             fdest.flush()
             #fdest.close()
             print "Utilisation du fichier temporaire %s" % fdest.name
             #truncateRomFile("tmp" + "/" + nameDest, dest + "/" + nameDest)
             truncateRomFile(fdest.name, dest + "/" + nameDest)
             fdest.close()
             #os.remove("tmp" + "/" + nameDest)
         fp.close()
     writeInfo("Ecriture Finie")
Ejemplo n.º 2
0
 def extractFromFileAndCrc(self, crc, dest):
     if not gotLib7z:
         writeError("Sorry, You cannot use 7z file")
         return False
     writeInfo("Extract 7Z file")
     fp = open(self.file, "rb")
     archive = Archive7z(fp)
     for name in archive.getnames():
         fd = archive.getmember(name)
         crcFd = getCRCFromBuffer(fd.read())
         if crc == crcFd:
             writeInfo("On extracte un 7z %s" % file)
             fd.reset()
             data = fd.read()
             nameDest = os.path.basename(name)
             writeInfo("On extract du 7z " + nameDest)
             fdest = NamedTemporaryFile()
             # fdest = open("tmp" + "/" + nameDest, 'w+b', os.O_SYNC)
             fdest.write(data)
             fdest.flush()
             # fdest.close()
             print "Utilisation du fichier temporaire %s" % fdest.name
             # truncateRomFile("tmp" + "/" + nameDest, dest + "/" + nameDest)
             truncateRomFile(fdest.name, dest + "/" + nameDest)
             fdest.close()
             # os.remove("tmp" + "/" + nameDest)
         fp.close()
     writeInfo("Ecriture Finie")
Ejemplo n.º 3
0
 def extractFromFileAndCrc(self, crc, dest):
     fd = zipfile.ZipFile(self.file, "r")
     for name in fd.namelist():
         crcFd = getCRCFromInt(fd.getinfo(name).CRC)
         #crcFd = getCRCFromBuffer(fd.read(name))
         if crc == crcFd:
             writeInfo("On extracte un Zip %s" % name)
             data = fd.read(name)
             fdest = NamedTemporaryFile()
             #fdest = open("tmp" + "/" + name, 'w+b', os.O_SYNC)
             fdest.write(data)
             fdest.flush()
             #fdest.close()
             #truncateRomFile("tmp" + "/" + name, dest + "/" + name)
             truncateRomFile(fdest.name, dest + "/" + name)
             #os.remove("tmp" + "/" + name)
             fdest.close()
     writeInfo("Ecriture Finie")
Ejemplo n.º 4
0
 def extractFromFileAndCrc(self, crc, dest):
     fd = zipfile.ZipFile(self.file, "r")
     for name in fd.namelist():
         crcFd = getCRCFromInt(fd.getinfo(name).CRC)
         # crcFd = getCRCFromBuffer(fd.read(name))
         if crc == crcFd:
             writeInfo("On extracte un Zip %s" % name)
             data = fd.read(name)
             fdest = NamedTemporaryFile()
             # fdest = open("tmp" + "/" + name, 'w+b', os.O_SYNC)
             fdest.write(data)
             fdest.flush()
             # fdest.close()
             # truncateRomFile("tmp" + "/" + name, dest + "/" + name)
             truncateRomFile(fdest.name, dest + "/" + name)
             # os.remove("tmp" + "/" + name)
             fdest.close()
     writeInfo("Ecriture Finie")
Ejemplo n.º 5
0
 def extractFromFileAndCrc(self, crc, dest):
     tar = tarfile.open(archive, "r:gz")
     for file in tar:
         if file.isreg():
             fd = tar.extractfile(file)
             crcFd = getCRCFromBuffer(fd.read())
             fd.close()
             if crc == crcFd:
                 writeInfo("On extracte un TarGz %s" % file)
                 fd = tar.extractfile(file)
                 data = fd.read()
                 print file.__dict__
                 name = os.path.basename(file.name)
                 writeInfo("On extract du TarGz ", name)
                 fdest = NamedTemporaryFile()
                 #fdest = open("tmp" + "/" + name, 'w+b', os.O_SYNC)
                 fdest.write(data)
                 fdest.flush()
                 #fdest.close()
                 #truncateRomFile("tmp" + "/" + name, dest + "/" + name)
                 truncateRomFile(fdest.name, dest + "/" + name)
                 fdest.close()
                 #os.remove("tmp" + "/" + name)
     writeInfo("Ecriture Finie")
Ejemplo n.º 6
0
 def extractFromFileAndCrc(self, crc, dest):
     tar = tarfile.open(archive, "r:gz")
     for file in tar:
         if file.isreg():
             fd = tar.extractfile(file)
             crcFd = getCRCFromBuffer(fd.read())
             fd.close()
             if crc == crcFd:
                 writeInfo("On extracte un TarGz %s" % file)
                 fd = tar.extractfile(file)
                 data = fd.read()
                 print file.__dict__
                 name = os.path.basename(file.name)
                 writeInfo("On extract du TarGz ", name)
                 fdest = NamedTemporaryFile()
                 # fdest = open("tmp" + "/" + name, 'w+b', os.O_SYNC)
                 fdest.write(data)
                 fdest.flush()
                 # fdest.close()
                 # truncateRomFile("tmp" + "/" + name, dest + "/" + name)
                 truncateRomFile(fdest.name, dest + "/" + name)
                 fdest.close()
                 # os.remove("tmp" + "/" + name)
     writeInfo("Ecriture Finie")
Ejemplo n.º 7
0
 def extractFromFileAndCrc(self, crc, dest):
     import shutil
     writeInfo("On copie direct le fichier %s vers %s" %
               (self.file, dest + '/' + os.path.basename(self.file)))
     truncateRomFile(self.file, dest + '/' + os.path.basename(self.file))
Ejemplo n.º 8
0
    def extractFromFileAndCrc(self, crc, dest):
        import shutil

        writeInfo("On copie direct le fichier %s vers %s" % (self.file, dest + "/" + os.path.basename(self.file)))
        truncateRomFile(self.file, dest + "/" + os.path.basename(self.file))