centralcity, on Nov 30 2007, 11:23 AM, said:
I'm getting the Runtime Error 0 when I try to download the updater engine. It downloads apengine.script but as soon as the file shows up in the folder, I get the error. I'm getting the same error on two machines, one running XP-Pro, the other one running Vista. So far, the other modules are downloading ok, as long as I don't try to download the updater engine.
I'm also getting Runtime Error 0 when I try to download the updater engine. I also have trouble downloading the updates for Windows XP (x86). Somewhere along the way the download progress stops. If I try to restart apup and resume the update progress I get the runtime error 0.
I did have a go at rewritting apup as a python script it seems to work ok for the releases I tried (AutoPatcher Engine 5.6.81 + UZ and AutoPatcher for Windows XP (x86) - Beta v3.3). If anyones want's to try it out here it is:
from __future__ import with_statement
import urllib
import re
import os
import md5
import zipfile
import sys
import shutil
perc = -1;
scriptRE = re.compile('(?P<name>[a-zA-Z0-9.]+)=(?P<value>.*)')
wd = os.getcwd()
RDresponse = ""
def downloadFile(url, path, size=None):
if size!=None: print "\nDownloading (%sMB):\n-v %s\n-> %s" % (round(size/1024/1024, 2), url, path)
else: print "\nDownloading:\n-v %s\n-> %s" % (url, path)
global perc;
perc = -1;
path2 = getAbs(path)
checkDir(path2)
print " ",
f = urllib.urlretrieve(url, path2, downloadProgress)
print "Done"
def downloadProgress(*a):
progress = int(float(a[0]*a[1])/float(a[2])*100)/5
global perc
if (perc<progress):
print min(progress,20)*5,
perc = progress
def clearScreen(numlines=100):
if os.name == "posix":
os.system('clear')
elif os.name in ("nt", "dos", "ce"):
os.system('CLS')
else:
print '\n' * numlines
def chooseRelease():
releases = {}
release = 0
with open("releases.list", "r") as f:
for line in f:
result1 = scriptRE.search(line)
if result1!=None:
if result1.group("name")=="Name":
release += 1
releases[release] = {}
releases[release][result1.group("name")] = result1.group("value")
print ""
for release in releases:
print "%i. %s (%s)" % (release, releases[release]["Name"], releases[release]["SystemLanguage"])
selections = input("\nEnter the number for each release (comma separated) to download:")
#clearScreen()
if type(selections)==int: downloadRelease(releases, selections)
else: downloadReleases(releases, selections)
def downloadReleases(releases, selections):
for selection in selections:
downloadRelease(releases, selection)
def downloadRelease(releases, selection):
print "\nDownloading release '%s'..." % releases[selection]["Name"]
dest = releases[selection]["Script"][releases[selection]["Script"].rindex("/")+1:]
downloadFile(releases[selection]["Script"], dest)
#get files we need to download
fileSets = parseScript(dest)
#get updates
getUpdates(fileSets)
def parseScript(path):
fileSets = {}
fileSetNum = -1
fileNum = -1;
previous = "";
with open(getAbs(path), "r") as f:
for line in f:
result1 = scriptRE.search(line)
if result1!=None:
if result1.group("name")=="PreAction":
os.popen(result1.group("value").replace("autopatcher:", wd));
if result1.group("name")=="PreAction.FileDelete":
path = getAbs(result1.group("value")[13:]);
if os.path.exists(path): os.remove(path)
if result1.group("name")=="PreAction.FolderDelete":
path = getAbs(result1.group("value")[13:]);
if os.path.exists(path): shutil.rmtree(path)
if result1.group("name")=="Item":
fileSetNum += 1
fileSets[fileSetNum] = {}
fileSets[fileSetNum]["Files"] = {}
fileSets[fileSetNum]["NeedsUpdating"] = -1
fileNum = -1
if result1.group("name")=="DetectFile":
path = result1.group("value")[13:]
fileNum += 1
fileSets[fileSetNum]["Files"][fileNum] = {}
fileSets[fileSetNum]["Files"][fileNum][result1.group("name")] = path
if result1.group("name")=="DetectHash":
fileSets[fileSetNum]["Files"][fileNum][result1.group("name")] = result1.group("value")
check = checkFile(fileSets[fileSetNum]["Files"][fileNum]["DetectFile"], result1.group("value"))
if check>0:
fileSets[fileSetNum]["NeedsUpdating"] = check
if result1.group("name")=="DownloadFrom":
fileSets[fileSetNum][result1.group("name")] = result1.group("value")
if result1.group("name")=="DownloadTo":
fileSets[fileSetNum][result1.group("name")] = result1.group("value")[13:]
if result1.group("name")=="ExpectedSize":
fileSets[fileSetNum][result1.group("name")] = result1.group("value")
if result1.group("name")=="ExpectedHash":
fileSets[fileSetNum][result1.group("name")] = result1.group("value")
if result1.group("name")=="ActionAfterDownload.Unzip":
fileSets[fileSetNum][result1.group("name")] = result1.group("value")
if result1.group("name")=="ActionAfterDownload":
fileSets[fileSetNum][result1.group("name")] = result1.group("value")
return fileSets
def getUpdates(fileSets):
global RDresponse;
#get total size and count of updates
totalSize = 0
totalCount = 0
for fileSet in fileSets:
if fileSets[fileSet]["NeedsUpdating"]>0 and fileSets[fileSet]["DownloadFrom"]!="":
totalSize += float(fileSets[fileSet]["ExpectedSize"])
totalCount += 1
print "\n%i files (%sMB) need updating..." % (totalCount, round(totalSize/1024/1024, 2))
#get updates
for fileSet in fileSets:
if fileSets[fileSet]["NeedsUpdating"]>0 and fileSets[fileSet]["DownloadFrom"]!="":
#Ask user whether they want to redownload file
if fileSets[fileSet]["NeedsUpdating"]==1: reason = "exist! Download?"
else: reason = "match! Redownload?"
if (RDresponse!="ya" and RDresponse!="na"): RDresponse = raw_input("\nThe file '%s' (%sMB) does not %s (y/n/ya/na)" % (fileSets[fileSet]["DownloadTo"], round(float(fileSets[fileSet]["ExpectedSize"])/1024/1024, 2), reason))
if (RDresponse=="y" or RDresponse=="ya"):
downloadFile(fileSets[fileSet]["DownloadFrom"], fileSets[fileSet]["DownloadTo"], float(fileSets[fileSet]["ExpectedSize"]))
# if has an after download action
if "ActionAfterDownload.Unzip" in fileSets[fileSet]:
path = getAbs(fileSets[fileSet]["DownloadTo"])
pathDir = os.path.dirname(path)
if os.path.exists(path):
print "\nUnzipping '%s'..." % fileSets[fileSet]["DownloadTo"]
z = zipfile.ZipFile(path, "r")
for zf in z.infolist():
newpath = os.path.join(pathDir, zf.filename)
checkDir(newpath)
if not zf.filename.endswith("/"): file(newpath, 'wb').write(z.read(zf.filename))
#if (newpath.lower().endswith(".script")):
#print "new script "+newpath[len(wd)+1:]
#fileSets2 = parseScript(newpath[len(wd)+1:])
#getUpdates(fileSets2)
z.close()
if "ActionAfterDownload" in fileSets[fileSet]:
pass
def checkFile(path, sum=None, size=None):
#print path
if path=="rt\\uz.exe": return 0
path2 = getAbs(path)
#print path2
if os.path.exists(path2):
#if file exists but is wrong size, return false
if size!=None and size!=os.path.getsize(path2):
#response = raw_input("\nSize of '%s' does not match! Redownload? (y/n)" % path)
#if (response=="y"): return False
#else: return True
return 2
elif sum!=None and sum.upper()!=hashFile(path2):
#response = raw_input("\nSum of '%s' does not match! Redownload? (y/n)" % path)
#if (response=="y"): return False
#else: return True
return 3
else:
return 0
else:
return 1
def checkDir(fullpath):
fullpathDir = os.path.dirname(fullpath)
if not os.path.exists(fullpathDir): os.mkdir(fullpathDir)
def hashFile(path):
f = file(path,'rb');
m = md5.new();
readBytes = 1024;
totalBytes = 0;
while (readBytes):
readString = f.read(readBytes);
m.update(readString);
readBytes = len(readString);
totalBytes+=readBytes;
f.close()
return m.hexdigest().upper()
def getAbs(path):
#return "%s%s%s" % (wd, os.path.sep, path)
return os.path.join(wd, path)
#for arg in sys.argv[1:]:
#get releases.list
downloadFile("http://www.autopatcher.com/releases.list", "releases.list")
chooseRelease()
Just put that into
filename.py and run it from a command prompt (Requires
python to be installed though.)
Edited by andyco, 30 November 2007 - 11:51 AM.