diff --git a/direct/src/http/webNotifyDebug.py b/direct/src/http/webNotifyDebug.py index c5c9bc2b6c..e4826c6f66 100755 --- a/direct/src/http/webNotifyDebug.py +++ b/direct/src/http/webNotifyDebug.py @@ -1,18 +1,63 @@ from direct.task import Task from direct.http import WebRequest from direct.directnotify import DirectNotifyGlobal +import random, string class webNotifyDebug: - def __init__(self, portNumber = 8888): + def __init__(self, portNumber = 8888, username = None, password = None): self.portNumber = portNumber + self.username = username + self.password = password + self.passwordProtect = False + self.pageToHit = 'debug' + self.authTokens = [] self.web = WebRequest.WebRequestDispatcher() self.web.listenOnPort(int(self.portNumber)) # 'debug' will be the name of the page we have to hit - self.web.registerGETHandler('debug', self.debug) + # If both a username and password should be specified, then + # we will need to present a username and password prompt to the user + if self.username and self.password: + # set self.passwordProtect to True + self.passwordProtect = True + # Register 'debug' with the password prompt + self.web.registerGETHandler('debug', self.passwordPrompt) + self.web.registerGETHandler('authDebug', self.authDebug) + self.pageToHit = 'authDebug' + else: + self.web.registerGETHandler('debug', self.debug) self.startCheckingIncomingHTTP() - def listAllCategories(self, replyTo, optionalMessage = None): + def passwordPrompt(self, replyTo, **kw): + # This should get called if we need to prompt the user for + # a username and password. + try: + username = kw['username'] + password = kw['password'] + except KeyError: + # the user is probably making their initial connection to the + # password protected site. Present them with the login page + replyTo.respond('\n