diff --git a/direct/src/http/webAIInspector.py b/direct/src/http/webAIInspector.py new file mode 100755 index 0000000000..b5a7b7cdba --- /dev/null +++ b/direct/src/http/webAIInspector.py @@ -0,0 +1,343 @@ +"""This is a web based inspector for the AI System. It can be accessed via +http://hostname.domain:port/ai + +The hostname.domain would of course be the computer that the AI is running on. +The port will need to be defined when the instance is inited. + +""" + +import string, time, direct, inspect +from direct.directnotify.DirectNotifyGlobal import directNotify +from direct.http import WebRequest +from socket import gethostname +from direct.task.Task import Task +from sys import platform + +# Need to figure out which systeminfo module to import +if platform == 'win32': + from windowsSystemInfo import SystemInformation +else: + from linuxSystemInfo import SystemInformation + +if __debug__: + notify = directNotify.newCategory('AIWebInterface') + +class aiWebServer(SystemInformation): + def __init__(self, air, listenPort=8080): + SystemInformation.__init__(self) + self.listenPort = listenPort + # self.taskMgr = Task.TaskManager() + if __debug__: + print "Listen port set to: %d" % self.listenPort + # Start dispatcher + self.web = WebRequest.WebRequestDispatcher() + self.web.listenOnPort(self.listenPort) + self.localHostName = gethostname() + self.web.registerGETHandler('inspect', self.inspect) + self.web.registerGETHandler('systemInfo', self.systemInfo) + self.web.registerGETHandler('oType', self.oType) + self.web.registerGETHandler('oInst', self.oInst) + self.web.registerGETHandler('blank', self.blank) + self.startCheckingIncomingHTTP() + + def timeStamp(self): + # Returns the local time in the following string format: + # Month-Day-Year Hour:Minute:Seconds + # Example: 09-17-2007 15:36:04 + return time.strftime("%m-%d-%Y %H:%M:%S", time.localtime()) + + def blank(self, replyTo, **kw): + # This simple generates a blank page for the middle and right + # frames;( for when the page is first accessed) + replyTo.respond('\n\n
\n\n