Posted by instaget on March Wed 21st 6:55 PM - Never Expires
download | new post
- #! /usr/bin/python
- import os
- import zipfile
- from glob import glob
- def getZipHash(thezip):
- # This retrieves the md5 sum from the md5hash file in the zip file
- f = zipfile.ZipFile(thezip, "r")
- line = f.read(thezip[5:] + ".md5")
- return line[:32]
- def downloadHashes():
- # Will need to get all of the file.zip.md5 files
- os.system("wget -N http://instagib.jorgepena.be/downloads/packages/bots.pk3.md5")
- os.system("wget -N http://instagib.jorgepena.be/downloads/packages/maps.pk3.md5")
- os.system("wget -N http://instagib.jorgepena.be/downloads/packages/media.pk3.md5")
- os.system("wget -N http://instagib.jorgepena.be/downloads/packages/players.pk3.md5")
- os.system("wget -N http://instagib.jorgepena.be/downloads/packages/scripts.pk3.md5")
- os.system("wget -N http://instagib.jorgepena.be/downloads/packages/sound.pk3.md5")
- os.system("wget -N http://instagib.jorgepena.be/downloads/packages/textures.pk3.md5")
- os.system("wget -N http://instagib.jorgepena.be/downloads/packages/ui.pk3.md5")
- def downloadFile(thefile):
- # This downloads the updated file
- url = "http://instagib.jorgepena.be/downloads/packages/" + thefile
- dest = "base/" + thefile
- print "Downloading " + thefile + " from " + url + " to " + dest
- os.system("wget -P base/ " + url + " -N")
- # We should first download the hashes
- downloadHashes()
- failed = 0 # This will check how many updates are needed
- for pk3 in glob("base/*.pk3"):
- f = open(pk3[5:] + ".md5", "r")
- rHash = f.readline()[:32]
- lHash = getZipHash(pk3)
- print "---------------------------------------------"
- print "File: " + pk3
- print "Remote Hash: " + rHash
- print "Local Hash: " + lHash
- if (lHash != rHash):
- print "MD5 Hash Mismatch..."
- failed = failed + 1
- downloadFile(pk3[5:])
- else:
- print "Successful match"
- print "---------------------------------------------"
- if failed == 0:
- print "No updates available"
- else:
- print "Downloaded " + string(failed) + " updates"
- # Remove the .md5 files
- print "Removing the MD5 Hash files..."
- os.system("rm *.md5")
Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.