comparison orpg/networking/mplay_server_gui.py @ 122:36919b8a3ef9 alpha

Traipse Alpha 'OpenRPG' {091031-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Cleaning up for Beta) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log Mercurial's hgweb folder is ported to upmana Happy Halloween!
author sirebral
date Sat, 31 Oct 2009 22:07:55 -0500
parents 9314d63c0941
children 8827271fbe1b
comparison
equal deleted inserted replaced
121:496dbf12a6cb 122:36919b8a3ef9
7 __appname__=' OpenRPG GUI Server v0.7 ' 7 __appname__=' OpenRPG GUI Server v0.7 '
8 __version__='$Revision: 1.26 $'[11:-2] 8 __version__='$Revision: 1.26 $'[11:-2]
9 __cvsinfo__='$Id: mplay_server_gui.py,v 1.26 2007/11/06 00:32:39 digitalxero Exp $'[5:-2] 9 __cvsinfo__='$Id: mplay_server_gui.py,v 1.26 2007/11/06 00:32:39 digitalxero Exp $'[5:-2]
10 __doc__="""OpenRPG Server Graphical Interface""" 10 __doc__="""OpenRPG Server Graphical Interface"""
11 11
12 import os 12 import os, sys, time, types
13 import sys 13
14 import time
15 import types
16 from orpg.dirpath import dir_struct 14 from orpg.dirpath import dir_struct
17 #import orpg.systempath looks old 15 #import orpg.systempath looks old
18 from orpg.tools.validate import validate 16 from orpg.tools.validate import validate
19 from orpg.orpg_wx import * 17 from orpg.orpg_wx import *
20 import webbrowser 18 import webbrowser
21 from threading import Thread 19 from threading import Thread
22 from meta_server_lib import post_server_data, remove_server 20 from meta_server_lib import post_server_data, remove_server
23 from mplay_server import mplay_server, server 21 from mplay_server import mplay_server, server
24 from xml.dom import minidom 22 from xml.dom import minidom
25 from orpg.orpgCore import component 23 from orpg.orpgCore import component
24 from orpg.tools.orpg_log import debug
25
26 from xml.etree.ElementTree import ElementTree, Element, iselement
27 from xml.etree.ElementTree import fromstring, tostring, parse
26 28
27 # Constants ###################################### 29 # Constants ######################################
28 SERVER_RUNNING = 1 30 SERVER_RUNNING = 1
29 SERVER_STOPPED = 0 31 SERVER_STOPPED = 0
30 MENU_START_SERVER = wx.NewId() 32 MENU_START_SERVER = wx.NewId()
89 self.func = func 91 self.func = func
90 self.message = message 92 self.message = message
91 93
92 # ServerConfig Object ############################ 94 # ServerConfig Object ############################
93 class ServerConfig: 95 class ServerConfig:
96 debug()
94 """ This class contains configuration 97 """ This class contains configuration
95 setting used to control the server.""" 98 setting used to control the server."""
96 99
97 def __init__(self, owner ): 100 def __init__(self, owner ):
98 """ Loads default configuration settings.""" 101 """ Loads default configuration settings."""
113 pass 116 pass
114 117
115 # Server Monitor ################################# 118 # Server Monitor #################################
116 119
117 class ServerMonitor(Thread): 120 class ServerMonitor(Thread):
121 debug()
118 """ Monitor thread for GameServer. """ 122 """ Monitor thread for GameServer. """
119 def __init__(self, cb, conf, name, pwd): 123 def __init__(self, cb, conf, name, pwd):
120 """ Setup the server. """ 124 """ Setup the server. """
121 Thread.__init__(self) 125 Thread.__init__(self)
122 self.cb = cb 126 self.cb = cb
123 self.conf = conf 127 self.conf = conf
124 self.serverName = name 128 self.serverName = name
125 self.bootPwd = pwd 129 self.bootPwd = pwd
126 130
127 def log(self, mesg): 131 def log(self, mesg):
132 debug()
128 if type(mesg) == types.TupleType: 133 if type(mesg) == types.TupleType:
129 func, msg = mesg 134 func, msg = mesg
130 event = MessageFunctionEvent( func, msg ) 135 event = MessageFunctionEvent( func, msg )
131 else: event = MessageLogEvent( mesg ) 136 else: event = MessageLogEvent( mesg )
132 wx.PostEvent( self.conf.owner, event ) 137 wx.PostEvent( self.conf.owner, event )
133 del event 138 del event
134 139
135 def run(self): 140 def run(self):
141 debug()
136 """ Start the server. """ 142 """ Start the server. """
137 self.server = mplay_server(self.log, self.serverName ) 143 self.server = mplay_server(self.log, self.serverName )
138 self.server.initServer(bootPassword=self.bootPwd, reg="No") 144 self.server.initServer(bootPassword=self.bootPwd, reg="No")
139 self.alive = 1 145 self.alive = 1
140 while self.alive: time.sleep(3) 146 while self.alive: time.sleep(3)
141 147
142 def stop(self): 148 def stop(self):
149 debug()
143 """ Stop the server. """ 150 """ Stop the server. """
144 self.server.kill_server() 151 self.server.kill_server()
145 self.alive = 0 152 self.alive = 0
146 153
147 # GUI Server ##################################### 154 # GUI Server #####################################
202 i = self.InsertImageStringItem( 0, player["id"], 0 ) 209 i = self.InsertImageStringItem( 0, player["id"], 0 )
203 self.SetStringItem(i, 1, self.stripHtml(player["name"])) 210 self.SetStringItem(i, 1, self.stripHtml(player["name"]))
204 self.SetStringItem(i, 2, "NEW") 211 self.SetStringItem(i, 2, "NEW")
205 self.SetStringItem(i, 3, self.roomList[0]) 212 self.SetStringItem(i, 3, self.roomList[0])
206 self.SetStringItem(i, 4, self.stripHtml(player["version"])) 213 self.SetStringItem(i, 4, self.stripHtml(player["version"]))
214 print self.stripHtml(player["role"])
207 self.SetStringItem(i, 5, 'Lurker' if self.stripHtml(player["role"]) == '' else self.stripHtml(player["role"])) 215 self.SetStringItem(i, 5, 'Lurker' if self.stripHtml(player["role"]) == '' else self.stripHtml(player["role"]))
208 self.SetStringItem(i, 6, self.stripHtml(player["ip"])) 216 self.SetStringItem(i, 6, self.stripHtml(player["ip"]))
209 self.SetStringItem(i, 7, "PING") 217 self.SetStringItem(i, 7, "PING")
210 self.SetItemData(i, int(player["id"])) 218 self.SetItemData(i, int(player["id"]))
211 self.AutoAjust() 219 self.AutoAjust()
229 def update(self, player): 237 def update(self, player):
230 i = self.FindItemData( -1, int(player["id"]) ) 238 i = self.FindItemData( -1, int(player["id"]) )
231 if i > -1: 239 if i > -1:
232 self.SetStringItem(i, 1, self.stripHtml(player["name"])) 240 self.SetStringItem(i, 1, self.stripHtml(player["name"]))
233 self.SetStringItem(i, 2, self.stripHtml(player["status"])) 241 self.SetStringItem(i, 2, self.stripHtml(player["status"]))
242 print self.stripHtml(player["role"])
234 self.SetStringItem(i, 5, 'Lurker' if self.stripHtml(player["role"]) == '' else self.stripHtml(player["role"])) 243 self.SetStringItem(i, 5, 'Lurker' if self.stripHtml(player["role"]) == '' else self.stripHtml(player["role"]))
235 self.AutoAjust() 244 self.AutoAjust()
236 else: self.add(player) 245 else: self.add(player)
237 246
238 def updateRoom( self, data ): 247 def updateRoom( self, data ):
456 # Event handler for out logging event 465 # Event handler for out logging event
457 def OnLogMessage( self, event ): 466 def OnLogMessage( self, event ):
458 self.Log( event.message ) 467 self.Log( event.message )
459 468
460 # Event handler for out logging event 469 # Event handler for out logging event
461 def OnFunctionMessage( self, event ): 470 def OnFunctionMessage(self, event):
471 debug()
462 self.callbacks[event.func]( event.message ) 472 self.callbacks[event.func]( event.message )
463 473
464 ### Server Callbacks ##################################### 474 ### Server Callbacks #####################################
465 def Log(self, log): 475 def Log(self, log):
466 wx.LogMessage(str(log)) 476 wx.LogMessage(str(log))