This repository has been archived by the owner on May 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created new SVN and imported 2.0 into it
- Loading branch information
pjbutler
committed
Dec 23, 2006
0 parents
commit 57fcb4e
Showing
21 changed files
with
2,924 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
This file and all included files are part of the WoW Addon Updater unless | ||
otherwise noted | ||
|
||
WoW Addon Updater is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
|
||
WoW Addon Updater is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with WoW Addon Updater; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/python | ||
''' | ||
This part of the prgram updates any program files that need updating and then | ||
runs the actual program. | ||
''' | ||
__author__ = "Patrick Butler <pbutler@killertux.org>" | ||
__version__ = "$Revision: 31 $" | ||
__copyright__ = "Copyright 2005,2006 Patrick Butler" | ||
__license__ = "GPL Version 2" | ||
|
||
import shutil | ||
import os.path | ||
import sys | ||
import urllib | ||
import socket | ||
from zipfile import ZipFile; | ||
import md5 | ||
import UpdateXML | ||
#import updater_gui | ||
|
||
macZip = "" | ||
winZip = "library.zip" | ||
updatesDir = "updates" | ||
xmlurl = "http://wowaddonupdater.sf.net/updates/updates.xml" | ||
|
||
def md5FromFile(file): | ||
if not os.path.exists(file): | ||
return None | ||
try: | ||
bytes = open(file,"r").read() | ||
return md5.new(bytes).hexdigest() | ||
except: | ||
return None | ||
|
||
def md5FromZip(zip, file): | ||
if not os.path.exists( zip ): | ||
return None | ||
try: | ||
zf = ZipFile(zip, "r") | ||
if file in zf.namelist(): | ||
bytes = zf.read(file) | ||
return md5.new(bytes).hexdigest() | ||
else: | ||
return None | ||
except: | ||
return None | ||
|
||
if __name__ == "__main__": | ||
theZip = winZip | ||
sys.path.insert(0, updatesDir) | ||
socket.setdefaulttimeout(5) | ||
updatedFileset = [] | ||
try: | ||
xml = urllib.urlopen(xmlurl).read() | ||
if not xml[:7] == "<files>": | ||
raise IOError, "Inavalid file" | ||
files = UpdateXML.parseString(xml) | ||
if not os.path.isdir(updatesDir): | ||
os.makedirs(updatesDir) | ||
if not os.path.isdir( os.path.join(updatesDir, ".tmp") ): | ||
os.makedirs( os.path.join(updatesDir, ".tmp") ) | ||
safe = True | ||
for f in files.keys(): | ||
xmlhash = files[f]['md5'] | ||
tmpfile = os.path.join(updatesDir, ".tmp", f) | ||
updatesFile = os.path.join(updatesDir, f) | ||
curmd5 = md5FromFile( updatesFile ) | ||
if curmd5 == None: | ||
curmd5 = md5FromZip(f, theZip) | ||
if xmlhash != curmd5: | ||
print "Downloading update for", f | ||
url = files[f]['source'] | ||
urllib.urlretrieve(url, tmpfile) | ||
tmpmd5 = md5FromFile( tmpfile ) | ||
#print tmpfile, tmpmd5, files[f]['md5'] | ||
if tmpmd5 != xmlhash: | ||
raise IOError, "Bad download %s!=%s" % ( xmlhash, tmpmd5) | ||
updatedFileset.append( (tmpfile, updatesFile) ) | ||
|
||
for tup in updatedFileset: | ||
(t, u) = tup | ||
if os.path.exists( u ): | ||
os.unlink( u ) | ||
shutil.move(t, u) | ||
except IOError, e: | ||
print "Update error", e | ||
shutil.rmtree( os.path.join( updatesDir, ".tmp"), True) | ||
|
||
import updater_gui | ||
app = updater_gui.UpdaterApp(0) | ||
app.MainLoop() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/python | ||
''' | ||
This little gem parses the XML file that describes where to download the | ||
updates from/ | ||
''' | ||
|
||
__author__ = "Patrick Butler <pbutler@killertux.org>" | ||
__version__ = "$Revision: 31 $" | ||
__copyright__ = "Copyright 2005,2006 Patrick Butler" | ||
__license__ = "GPL Version 2" | ||
|
||
import sys | ||
|
||
import xml | ||
from xml.dom.minidom import parse, parseString | ||
from xml.dom import minidom, Node | ||
|
||
def readFileNode(file): | ||
|
||
ret = { 'source': None, 'dir': None, 'name': None, 'md5': None } | ||
for node in file.childNodes: | ||
if node.nodeType == Node.ELEMENT_NODE: | ||
if node.nodeName == "source" or node.nodeName == "dir" or node.nodeName == "name" or node.nodeName == "md5": | ||
if node.childNodes == []: | ||
continue | ||
if node.childNodes[0].nodeType == Node.TEXT_NODE: | ||
ret[node.nodeName] = node.childNodes[0].nodeValue | ||
return ret | ||
|
||
def walkNodes(doc): | ||
ret = {} | ||
listFiles = doc.getElementsByTagName('files') | ||
#if no root node or no file nodes | ||
if listFiles == None: | ||
return None | ||
|
||
for files in listFiles: | ||
for f in files.childNodes: | ||
data = readFileNode(f) | ||
key = data['name'] | ||
if key == None: | ||
continue | ||
if data['dir'] != None: | ||
key = data['dir'] + "/" + key | ||
ret[key] = data | ||
return ret | ||
|
||
def parse(s): | ||
try : | ||
doc = minidom.parse(s) | ||
return walkNodes(doc) | ||
except xml.parsers.expat.ExpatError: | ||
return None | ||
|
||
def parseString(fn): | ||
try: | ||
doc = minidom.parseString(fn) | ||
return walkNodes(doc) | ||
except xml.parsers.expat.ExpatError: | ||
return None | ||
|
||
|
||
if __name__ == '__main__': | ||
s =""" | ||
<files> | ||
<file> | ||
<dir></dir> | ||
<name>test.py</name> | ||
<source>http://nowhere.com/test.py</source> | ||
<md5>blahbalh</md5> | ||
</file> | ||
</files> | ||
""" | ||
if len(sys.argv) > 1: | ||
print parse(sys.argv[1]) | ||
else: | ||
print parseString(s) |
Oops, something went wrong.