J'essaie d'extraire les nouvelles révisions de Chromium.app à partir de leurs instantanés, et je peux télécharger le fichier correctement, mais quand il s'agit de l'extraire, ZipFile extrait le dossier chrome-mac en tant que fichier, dit que les répertoires n'existent pas, etc. Je suis très nouveau sur python, donc ces erreurs ont peu de sens pour moi. Voici ce que j'ai jusqu'ici.Extraire un fichier .app à partir d'un fichier zip en Python, en utilisant ZipFile
import urllib2
response = urllib2.urlopen('http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/LATEST')
latestRev = response.read()
print latestRev
# we have the revision, now we need to download the zip and extract it
latestZip = urllib2.urlopen('http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/%i/chrome-mac.zip' % (int(latestRev)), '~/Desktop/ChromiumUpdate/%i-update' % (int(latestRev)))
#declare some vars that hold paths n shit
workingDir = '/Users/slehan/Desktop/ChromiumUpdate/'
chromiumZipPath = '%s%i-update.zip' % (workingDir, (int(latestRev)))
chromiumAppPath = 'chrome-mac/' #the path of the chromium executable within the zip file
chromiumAppExtracted = '%s/Chromium.app' % (workingDir) # path of the extracted executable
output = open(chromiumZipPath, 'w') #delete any current file there
output.write(latestZip.read())
output.close()
# we have the .zip now we need to extract the Chromium.app file, it's in ziproot/chrome-mac/Chromium.app
import zipfile, os
zippedFile = open(chromiumZipPath)
zippedChromium = zipfile.ZipFile(zippedFile, 'r')
zippedChromium.extract(chromiumAppPath, workingDir)
#print zippedChromium.namelist()
zippedChromium.close()
#zippedChromium.close()
Des idées?
Eh bien beurrer mon cul et appelez-moi Susan, j'ai mis à jour et ça marche maintenant. – skylerl