Hi have code from the manual and it says downloadtask not defined. here is the code
http = HTTPClient()
channel = http.makeChannel(True)
channel.beginGetDocument(DocumentSpec('http://cdn.toontownreborn.tk/viewer/win32/'))
rf = Ramfile()
channel.downloadToRam(rf)
taskMgr.add(downloadTask, 'download')
def downloadTask(self, task):
if self.channel.run():
# Still waiting for file to finish downloading.
return task.cont
if not channel.isDownloadComplete():
print "Error downloading file."
return task.done
data = rf.getData()
print "got data:"
print data
return task.done
channel.downloadToFile(toontown.exe(toontown.exe))
Looking at the manual page from which this seems to come, I see that the code given there uses the “self.” prefix, implying that the snippet was intended to be used from within a class.
If you don’t want to use a class, then I believe that the code can be fixed by moving the lines before the definition of the method to a point after the end of the method, so that the method has been defined by the point at which those lines are executed.
Now I get downloadTask takes 2 arguments and 1 given the code now looks like this
def downloadTask(self, task):
print "download is starting"
if channel.run():
# Still waiting for file to finish downloading.
return task.cont
if not self.channel.isDownloadComplete():
print "Error downloading file."
return task.done
data = rf.getData()
print "got data:"
print data
return task.done
http = HTTPClient()
channel = http.makeChannel(True)
channel.beginGetDocument(DocumentSpec('http://cdn.toontownreborn.tk/viewer/win32/toontown.exe'))
rf = Ramfile()
channel.downloadToRam(rf)
taskMgr.add(downloadTask, 'download')
wezu
January 5, 2015, 7:27pm
4
Try:
def downloadTask(task):
This may help if you don’t know why:
www.voidspace.org.uk/python/articles/OO … -parameter
Thanks it works now! All 'I need to do now is make a patcher.ver so it knows what to download.
Edit: Now when it downloads the update it gives windows error code 0. And I forgot what it means!