comparison orpg/networking/server_plugins.py @ 92:68c7bd272f27 beta

Traipse Beta 'OpenRPG' {090919-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: Adds menu changes to draw attention to important updates, errors, or other events. (image info coming soon) Traipse URL is not included in the repos tab and is set as default. Fixes Copy for Windows and Linux (finally!!) users. Fixes incomplete update to Grid and List nodes. Fixes incomplete update to Chat Commands. Fixes problems with Remote Image Upload. Fixes Drop and Drag of Minis to Map. CherryPy can now use any image in the webfiles/ folder and sub-folders. CherryPy can now Drop and Drag Minis to the Map. Minor changes to Update Manager's GUI. Expert recommendation warning added to Revision Update. Step down compatibility with open_rpg & component added to orpgCore. Using majority of 'Grumpy' network folder to correct server lag.
author sirebral
date Sat, 19 Sep 2009 06:50:43 -0500
parents 449a8900f9ac
children 65c1604e7949
comparison
equal deleted inserted replaced
84:5c12918d6bb2 92:68c7bd272f27
22 self.__ptype = ptype 22 self.__ptype = ptype
23 self.__plugins = {} 23 self.__plugins = {}
24 24
25 def initBase(self): 25 def initBase(self):
26 self._startPlugins() 26 self._startPlugins()
27
27 28
28 #Methods 29 #Methods
29 def _startPlugins(self): 30 def _startPlugins(self):
30 autoload = [] 31 autoload = []
31 #Fill autoload from some file with the Plugin Names 32 #Fill autoload from some file with the Plugin Names
57 58
58 #Now Load it 59 #Now Load it
59 self._load(pluginData) 60 self._load(pluginData)
60 61
61 #Write to the autoload file for this plugin 62 #Write to the autoload file for this plugin
63
62 self.__plugins[pluginName].Activated = True 64 self.__plugins[pluginName].Activated = True
63 self.__plugins[pluginName].start() 65 self.__plugins[pluginName].start()
64 66
65 def deactivatePugin(self, pluginData): 67 def deactivatePugin(self, pluginData):
66 if not self.__plugins.has_key(pluginName): 68 if not self.__plugins.has_key(pluginName):
67 #Print some error about invalid plugin 69 #Print some error about invalid plugin
68 return 70 return
71 pluginData = self.__plugins[pluginName]
69 72
70 pluginData = self.__plugins[pluginName]
71 self.__plugins[pluginName].stop() 73 self.__plugins[pluginName].stop()
72 74
73 #Unload it 75 #Unload it
74 self._unload(pluginData) 76 self._unload(pluginData)
77
75 #Remove this plugin from the autoload file 78 #Remove this plugin from the autoload file
76 79
77 #Private Methods 80 #Private Methods
78 def _findModule(self, pluginFile): 81 def _findModule(self, pluginFile):
79 s1 = pluginFile.split(os.sep) 82 s1 = pluginFile.split(os.sep)
80 s2 = s1[-1].split('.') 83 s2 = s1[-1].split('.')
81 return ('plugins.' + self.__ptype + '.' + s2[0], s2[0]) 84 return ('plugins.' + self.__ptype + '.' + s2[0], s2[0])
82 85
83 def _unload(self, pluginData): 86 def _unload(self, pluginData):
84 self.__plugins[pluginData.Name] = PluginData(pluginData.Name, 87 self.__plugins[pluginData.Name] = PluginData(pluginData.Name, pluginData.File, pluginData.Author, pluginData.Help)
85 pluginData.File,
86 pluginData.Author,
87 pluginData.Help)
88 unload = [] 88 unload = []
89 mod = self._findModule(pluginData.File)[0] 89 mod = self._findModule(pluginData.File)[0]
90 for key, module in sys.modules.iteritems(): 90 for key, module in sys.modules.iteritems():
91 if str(module).find(mod) > -1: 91 if str(module).find(mod) > -1:
92 unload.append(key) 92 unload.append(key)
113 def _getPlugins(self): 113 def _getPlugins(self):
114 return self.__plugins 114 return self.__plugins
115 115
116 def _getType(self): 116 def _getType(self):
117 return self.__ptype 117 return self.__ptype
118
119
118 #Properties 120 #Properties
119 Plugins = property(_getPlugins, None) 121 Plugins = property(_getPlugins, None)
120 Type = property(_getType, None) 122 Type = property(_getType, None)
121 123
122 class ServerPluginsClass(BasePluginsClass): 124 class ServerPluginsClass(BasePluginsClass):
128 self.initBase() 130 self.initBase()
129 131
130 def preParseIncoming(self, xml_dom, data): 132 def preParseIncoming(self, xml_dom, data):
131 sent = True 133 sent = True
132 errmsg = "" 134 errmsg = ""
135
133 for pluginName, pluginData in self.Plugins.iteritems(): 136 for pluginName, pluginData in self.Plugins.iteritems():
134 if pluginData.Activated: 137 if pluginData.Activated:
135 xml_dom, data = pluginData.preParseIncoming(xml_dom, data) 138 xml_dom, data = pluginData.preParseIncoming(xml_dom, data)
139
136 return xml_dom, data 140 return xml_dom, data
137 141
138 def postParseIncoming(self, data): 142 def postParseIncoming(self, data):
139 for pluginName, pluginData in self.Plugins.iteritems(): 143 for pluginName, pluginData in self.Plugins.iteritems():
140 if pluginData.Activated: 144 if pluginData.Activated:
141 data = pluginData.postParseIncoming(data) 145 data = pluginData.postParseIncoming(data)
146
142 return data 147 return data
143 148
144 def getPlayer(self): 149 def getPlayer(self):
145 players = [] 150 players = []
146 for pluginName, pluginData in self.Plugins.iteritems(): 151 for pluginName, pluginData in self.Plugins.iteritems():
147 if pluginData.Activated: 152 if pluginData.Activated:
148 playerName = pluginData.addPlayer(data) 153 playerName = pluginData.addPlayer(data)
149 players.append(playerName) 154 players.append(playerName)
155
150 return players 156 return players
151 157
152 def setPlayer(self, playerData): 158 def setPlayer(self, playerData):
153 players = [] 159 players = []
154 for pluginName, pluginData in self.Plugins.iteritems(): 160 for pluginName, pluginData in self.Plugins.iteritems():
155 if pluginData.Activated: 161 if pluginData.Activated:
156 playerName = pluginData.addPlayer(data) 162 playerName = pluginData.addPlayer(data)
157 players.append(playerName) 163 players.append(playerName)
164
158 return 165 return
159 166
160 def preParseOutgoing(self): 167 def preParseOutgoing(self):
161 data = [] 168 data = []
162 for pluginName, pluginData in self.Plugins.iteritems(): 169 for pluginName, pluginData in self.Plugins.iteritems():
163 if pluginData.Activated: 170 if pluginData.Activated:
164 xml = pluginData.preParseOutgoing() 171 xml = pluginData.preParseOutgoing()
165 for msg in xml: 172 for msg in xml:
166 data.append(msg) 173 data.append(msg)
174
167 return data 175 return data
168 176
169 def postParseOutgoing(self): 177 def postParseOutgoing(self):
170 data = [] 178 data = []
171 for pluginName, pluginData in self.Plugins.iteritems(): 179 for pluginName, pluginData in self.Plugins.iteritems():
172 if pluginData.Activated: 180 if pluginData.Activated:
173 xml = pluginData.postParseOutgoing() 181 xml = pluginData.postParseOutgoing()
174 for msg in xml: 182 for msg in xml:
175 data.append(msg) 183 data.append(msg)
184
176 return data 185 return data
177 186
178 __key = _SingletonKey() 187 __key = _SingletonKey()
179 ServerPlugins = ServerPluginsClass(__key) 188 ServerPlugins = ServerPluginsClass(__key)