diff --git a/direct/src/http/webAIInspector.py b/direct/src/http/webAIInspector.py index 19490591f6..5e9f9cf8de 100755 --- a/direct/src/http/webAIInspector.py +++ b/direct/src/http/webAIInspector.py @@ -1,5 +1,5 @@ """This is a web based inspector for the AI System. It can be accessed via -http://hostname.domain:port/ai +http://hostname.domain:port/inspect 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. @@ -12,6 +12,8 @@ from direct.http import WebRequest from socket import gethostname from direct.task.Task import Task from sys import platform +from pirates.uberdog.AIMagicWordTrade import AIMagicWordTrade +from pirates.quest.QuestDB import QuestDict # Need to figure out which systeminfo module to import if platform == 'win32': @@ -26,6 +28,7 @@ class aiWebServer(SystemInformation): def __init__(self, air, listenPort=8080): SystemInformation.__init__(self) self.listenPort = listenPort + self.air = simbase.air # self.taskMgr = Task.TaskManager() if __debug__: print "Listen port set to: %d" % self.listenPort @@ -35,21 +38,157 @@ class aiWebServer(SystemInformation): self.localHostName = gethostname() self.web.registerGETHandler('inspect', self.inspect) self.web.registerGETHandler('systemInfo', self.systemInfo) + self.web.registerGETHandler('oMenu', self.oMenu) self.web.registerGETHandler('oType', self.oType) self.web.registerGETHandler('oInst', self.oInst) self.web.registerGETHandler('blank', self.blank) + self.web.registerGETHandler('magicWord', self.magicWord) self.startCheckingIncomingHTTP() + def magicWord(self, replyTo, **kw): + # This will process Magic Word requests + # Currently the following words are supported: + # ~aiobjectcount + # ~aitaskmgr + # ~aijobmgr + # ~assignQuest + # ~money + + # First we need to figure out which magic word is being called + try: + theMagicWord = kw['magicWord'] + except KeyError: + # MagicWord issue. Malformed URL + replyTo.respond('\n\n
\n\n%s\n' % (theMagicWord, simbase.air.webPrintObjectCount())) + return + elif theMagicWord == 'aitaskmgr': + replyTo.respond('\n\n\n\n
%s\n' % (theMagicWord, taskMgr)) + return + elif theMagicWord == 'aijobmgr': + replyTo.respond('\n\n\n\n
%s\n' % (theMagicWord, jobMgr)) + + elif theMagicWord == 'money': + # First, generate the Avatar HTML Select widget. + + selectWidget = self.genAvSelect() + + # Now that we've built the avatar list, we can repond with the HTML + + replyTo.respond('\n\n\n\n
Raw Object List\n')
+ return
+
+ def genAvSelect(self):
+ # We will need to populate HTML FORM menus to make this work.
+ # We will need to provide a list of Avatars on the AI
+ # along with a field to allow an int value to be sent
+ # First, we need to get a dict of DistributedPlayerPirateAI's
+
+ playerPirates = []
+ objList = self.generateSortedIDList()
+ objList.reverse()
+ while objList:
+ tempObjElement = objList.pop()
+ if str(tempObjElement[0]).find('DistributedPlayerPirateAI') != -1:
+ playerPirates.append(tempObjElement[1])
+
+ # OK, now playerPirates should be a list of avatar ids
+ # We should build a HTML select widget with the new list
+ selectWidget = '
\n' % selectWidget
+ return selectWidget
+
+ def genQuestSelect(self):
+ # Will generate an HTML select widget, with the Key vals from the QuestDB
+ selectWidget = '
\n' % selectWidget
+ return selectWidget
+
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