comparison orpg/networking/meta_server_lib.py @ 227:81d0bfd5e800 alpha

Traipse Alpha 'OpenRPG' {100612-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 (Preparing to close updates) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created
author sirebral
date Sat, 12 Jun 2010 03:50:37 -0500
parents 06f10429eedc
children
comparison
equal deleted inserted replaced
182:4b2884f29a72 227:81d0bfd5e800
20 # 20 #
21 # File: meta_server_lib.py 21 # File: meta_server_lib.py
22 # Author: Chris Davis 22 # Author: Chris Davis
23 # Maintainer: 23 # Maintainer:
24 # Version: 24 # Version:
25 # $Id: meta_server_lib.py,v 1.40 2007/04/04 01:18:42 digitalxero Exp $ 25 # $Id: meta_server_lib.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
26 # 26 #
27 # Description: A collection of functions to communicate with the meta server. 27 # Description: A collection of functions to communicate with the meta server.
28 # 28 #
29 29
30 30
31 #added debug flag for meta messages to cut console server spam --Snowdog 31 #added debug flag for meta messages to cut console server spam --Snowdog
32 META_DEBUG = 0 32 META_DEBUG = False
33 33
34 __version__ = "$Id: meta_server_lib.py,v 1.40 2007/04/04 01:18:42 digitalxero Exp $" 34 __version__ = "$Id: meta_server_lib.py,v 1.40 2007/04/04 01:18:42 digitalxero Exp $"
35 35
36 from orpg.orpg_version import PROTOCOL_VERSION 36 from orpg.orpg_version import PROTOCOL_VERSION
37 from orpg.orpgCore import component 37 from orpg.orpgCore import component
38 from orpg.tools.validate import validate 38 from orpg.tools.validate import validate
39 from orpg.dirpath import dir_struct 39 from orpg.dirpath import dir_struct
40 40
41 import urllib, time, sys, traceback, re 41 import urllib, time, sys, traceback, re
42 #import orpg.minidom
43 42
44 from threading import * 43 from threading import *
45 from random import uniform 44 from random import uniform
45 import urllib2
46 from urllib import urlopen, urlencode 46 from urllib import urlopen, urlencode
47 from orpg.tools.orpg_log import debug 47 from orpg.tools.orpg_log import debug
48 48
49 from xml.etree.ElementTree import Element, fromstring 49 from xml.etree.ElementTree import Element, fromstring, parse, tostring
50
51 metacache_lock = RLock() 50 metacache_lock = RLock()
52 51
53 def get_server_dom(data=None,path=None, string=False): 52 def get_server_dom(data=None, path=None, string=False):
54 # post data at server and get the resulting DOM 53 if path[len(path)-1] != "/": path += '/'
55 if path == None:
56 # get meta server URI
57 path = getMetaServerBaseURL()
58 54
59 # POST the data 55 # POST the data
60 if META_DEBUG: 56 if META_DEBUG:
61 print 57 print
62 print "Sending the following POST info to Meta at " + path + ":" 58 print "Sending the following POST info to Meta at " + path + ":"
63 print "==========================================" 59 print "=========================================="
64 print data 60 print data
65 print 61 print
66 file = urlopen(path, data) 62 #recvdata = urllib2.Request(path, data)
67 data = file.read() 63 response = urllib2.urlopen(path, data)
68 file.close() 64 data = response.read()
69 65
70 # Remove any leading or trailing data. This can happen on some satellite connections 66 # Remove any leading or trailing data. This can happen on some satellite connections
71 p = re.compile('(<servers>.*?</servers>)',re.DOTALL|re.IGNORECASE) 67 p = re.compile('(<servers>.*?</servers>)',re.DOTALL|re.IGNORECASE)
72 mo = p.search(data) 68 mo = p.search(data)
73 if mo: data = mo.group(0) 69 if mo: data = mo.group(0)
77 print "Got this string from the Meta at " + path + ":" 73 print "Got this string from the Meta at " + path + ":"
78 print "===============================================" 74 print "==============================================="
79 print data 75 print data
80 print 76 print
81 # build dom 77 # build dom
82 etreeEl = data 78 if string: return data
83 if not string: return fromstring(etreeEl) 79 else: return fromstring(data)
84 else: return etreeEl
85 80
86 def post_server_data(name, realHostName=None): 81 def post_server_data(name, realHostName=None):
87 if realHostName: data = urlencode({"server_data[name]":name, 82 if realHostName: data = urlencode({"server_data[name]":name,
88 "server_data[version]":PROTOCOL_VERSION, 83 "server_data[version]":PROTOCOL_VERSION,
89 "act":"new", 84 "act":"new",
90 "REMOTE_ADDR": realHostName }) 85 "REMOTE_ADDR": realHostName })
91 # print "Letting meta server decide the hostname to list..." 86 # print "Letting meta server decide the hostname to list..."
92 else: data = urlencode({"server_data[name]":name, 87 else: data = urlencode({"server_data[name]":name,
93 "server_data[version]":PROTOCOL_VERSION, 88 "server_data[version]":PROTOCOL_VERSION,
94 "act":"new"}) 89 "act":"new"})
95 path = component.get('settings').get('MetaServerBaseURL') #getMetaServerBaseURL() 90 path = component.get('settings').get('MetaServerBaseURL') #getMetaServerList()
96 etreeEl = get_server_dom(data, path) 91 etreeEl = get_server_dom(data, path)
97 return int(etreeEl.get('id')) 92 return int(etreeEl.get('id'))
98 93
99 def post_failed_connection(id,meta=None,address=None,port=None): 94 def post_failed_connection(id,meta=None,address=None,port=None):
100 # For now, turning this off. This needs to be re-vamped for 95 # For now, turning this off. This needs to be re-vamped for
111 return int(etreeEl.get("return")) 106 return int(etreeEl.get("return"))
112 107
113 def byStartAttribute(first, second): 108 def byStartAttribute(first, second):
114 # This function is used to easily sort a list of nodes by their start time 109 # This function is used to easily sort a list of nodes by their start time
115 # Ensure there is something to sort with for each 110 # Ensure there is something to sort with for each
116
117 first_start = int(first.get('start')) or 0 111 first_start = int(first.get('start')) or 0
118 second_start = int(second.get('start')) or 0 112 second_start = int(second.get('start')) or 0
119
120 # Return the result of the cmp function on the two strings 113 # Return the result of the cmp function on the two strings
121 return cmp(first_start, second_start) 114 return cmp(first_start, second_start)
122 115
123 def byNameAttribute(first, second): 116 def byNameAttribute(first, second):
124 # This function is used to easily sort a list of nodes by their name attribute 117 # This function is used to easily sort a list of nodes by their name attribute
125 # Ensure there is something to sort with for each 118 # Ensure there is something to sort with for each
126
127 first_name = first.get('name') or '' 119 first_name = first.get('name') or ''
128 second_name = second.get('name') or '' 120 second_name = second.get('name') or ''
129
130 # Return the result of the cmp function on the two strings 121 # Return the result of the cmp function on the two strings
131 return cmp(first_name,second_name) 122 return cmp(first_name,second_name)
132 123
133 124
134 def get_server_list(versions = None, sort_by="start"): 125 def get_server_list(versions=None, sort_by="start"):
135 data = urlencode({"version":PROTOCOL_VERSION,"ports":"%"}) 126 data = urlencode({"version":PROTOCOL_VERSION,"ports":"%"})
136 all_metas = getMetaServers(versions, 1) # get the list of metas 127 #all_metas = getMetaServers(versions, False) # get the list of metas
137 base_meta = getMetaServerBaseURL() 128 meta_list = getMetaServerList()
138
139 #all_metas.reverse() # The last one checked will take precedence, so reverse the order 129 #all_metas.reverse() # The last one checked will take precedence, so reverse the order
140 # so that the top one on the actual list is checked last 130 # so that the top one on the actual list is checked last
141 return_hash = {} # this will end up with an amalgamated list of servers 131 return_hash = {} # this will end up with an amalgamated list of servers
142 132
143 for meta in all_metas: # check all of the metas 133 for meta in meta_list: # check all of the metas
144 #get the server's xml from the current meta 134 #get the server's xml from the current meta
145 bad_meta = 0 135 bad_meta = 0
146 #print "Getting server list from " + meta + "..." 136 #print "Getting server list from " + meta + "..."
147 try: xml_dom = get_server_dom(data=data, path=meta) 137 try: xml_dom = get_server_dom(data, meta.get('url'))
148 except: bad_meta = 1 #print "Trouble getting servers from " + meta + "..." 138 except: bad_meta = 1; print "Trouble getting servers from " + meta.get('url') + "..."
149 if bad_meta: continue 139 if bad_meta: continue
150 if base_meta == meta: updateMetaCache(xml_dom) #print "This is our base meta: " + meta
151 node_list = xml_dom.findall('server') 140 node_list = xml_dom.findall('server')
152 if len(node_list): # if there are entries in the node list 141 if len(node_list):
153 # otherwise, just loop to next meta
154
155 # for each node found, we're going to check the nodes from prior
156 # metas in the list. If a match is found, then use the new values.
157 for n in node_list: 142 for n in node_list:
158 # set them from current node
159 if not n.get('name'): n.set('name','NO_NAME_GIVEN') 143 if not n.get('name'): n.set('name','NO_NAME_GIVEN')
160 name = n.get('name') 144 name = n.get('name')
161 if not n.get('num_users'): n.set('num_users','N/A') 145 if not n.get('num_users'): n.set('num_users','N/A')
162 num_users = n.get('num_users') 146 num_users = n.get('num_users')
163 if not n.get('address'): n.set('address','NO_ADDRESS_GIVEN') 147 if not n.get('address'): n.set('address','NO_ADDRESS_GIVEN')
165 if not n.get('port'): n.set('port','6774') 149 if not n.get('port'): n.set('port','6774')
166 port = n.get('port') 150 port = n.get('port')
167 n.set('meta',meta) 151 n.set('meta',meta)
168 end_point = str(address) + ":" + str(port) 152 end_point = str(address) + ":" + str(port)
169 if return_hash.has_key(end_point): 153 if return_hash.has_key(end_point):
154 print end_point
155 print n
156
170 if META_DEBUG: print "Replacing duplicate server entry at " + end_point 157 if META_DEBUG: print "Replacing duplicate server entry at " + end_point
171 return_hash[end_point] = n 158 return_hash[end_point] = n
172
173 # At this point, we have an amalgamated list of servers
174 # Now, we have to construct a new DOM to pass back.
175
176 # Create a servers element
177 server_list = Element('servers') 159 server_list = Element('servers')
178
179 # get the nodes stored in return_hash
180 sort_list = return_hash.values() 160 sort_list = return_hash.values()
181
182 # sort them by their name attribute. Uses byNameAttribute()
183 # defined above as a comparison function
184 if sort_by == "start": sort_list.sort(byStartAttribute) 161 if sort_by == "start": sort_list.sort(byStartAttribute)
185 elif sort_by == "name": sort_list.sort(byNameAttribute) 162 elif sort_by == "name": sort_list.sort(byNameAttribute)
186
187 # Add each node to the DOM
188 for n in sort_list: server_list.append(n) 163 for n in sort_list: server_list.append(n)
189 return server_list 164 return server_list
190 165
191 ## List Format: 166 ## List Format:
192 ## <servers> 167 ## <servers>
216 metacache_lock.release() 191 metacache_lock.release()
217 except Exception, e: 192 except Exception, e:
218 if META_DEBUG: traceback.print_exc() 193 if META_DEBUG: traceback.print_exc()
219 print "Meta Server Lib: UpdateMetaCache(): " + str(e) 194 print "Meta Server Lib: UpdateMetaCache(): " + str(e)
220 195
221 def getRawMetaList(path=None): 196
222 ### Alpha ### 197 def getMetaServerList():
223 """This code will allow for a list of metas to be created. Future developement will more integrate the list of metas""" 198 # get meta server URL
224 if path != None: 199 meta_list = fromstring("""
225 metas = [] 200 <metaservers>
226 data = urlencode({"version":PROTOCOL_VERSION,"ports":"%"}) 201 <meta url="http://orpgmeta.appspot.com" versions="1 2" />
227 xml_dom = get_server_dom(data, path) 202 <meta url="http://traipsemeta.madmathlabs.info" versions="1 2" />
228 node_list = fromstring(xml_dom).findall('meta_server') 203 </metaservers>"""
229 if len(node_list): 204 )
230 for n in node_list:
231 metas.append(n.get('path'))
232 return metas
233 try: 205 try:
234 try: 206 component.get('validate').config_file("metaservers.xml","default_metaservers.xml")
235 metacache_lock.acquire()
236 # Read in the metas
237 validate.config_file("metaservers.cache","metaservers.cache")
238 ini = open(dir_struct["user"]+"metaservers.cache","r")
239 metas = ini.readlines()
240 ini.close()
241 return metas
242 finally:
243 metacache_lock.release()
244 except Exception, e:
245 if META_DEBUG: traceback.print_exc()
246 print "Meta Server Lib: getRawMetaList(): " + str(e)
247 return []
248
249 def getMetaServers(versions = None, pick_random=0):
250 """
251 get meta server URLs as a list
252 versions is a list of acceptable version numbers.
253 A False truth value will use getMetaServerBaseURL()
254 set a default if we have weird reading problems
255 default_url = "http://www.openrpg.com/openrpg_servers.php"
256 """
257
258 ### Pre Alpha Design ###
259 """ Here is how to handle Multiple Meta servers, and probably the best way to do it. Create an XML file that contains nodes with the various servers. Users will grab that meta data and have the option to connect to multiple meta servers which will allow them to find all the rooms. A check box should be used so if one server faile the users can continue without much lag. When creating a server hosts will need to select a meta to go too. This should be in the final of Ornery Orc."""
260 meta_names = []
261 if(versions): # If versions are supplied, then look in metaservers.conf
262 try:
263 """
264 read in the metas from file
265 format of file is one meta entry per line
266 each entry will be the meta url, followed by one or more version numbers that it
267 handle. Generally, this will be either a 1 for the original Meta format, or
268 2 for the new one.
269 """
270 # Read in the metas
271 #Adding a path object will attempt to look for a meta_network.
272 metas = getRawMetaList()
273
274 # go through each one to check if it should be returned, based on the
275 # version numbers allowed.
276 for meta in metas:
277 # split the line on whitespace
278 # obviously, your meta servers urls shouldn't contain whitespace. duh.
279 words = meta.split()
280 success = 0 # init success flag for version check
281 for version in versions: # run through each allowed version from caller
282 if version in words[1:]: # if the allowed version token was found
283 success += 1 # then increment the success indicator
284 if success: # if the meta entry is acceptable to the caller
285 meta_names.append(words[0]) # add the entry
286 if META_DEBUG: print "adding metaserver " + meta
287
288 # at this point, we should have at least one name from the cache. If not ...
289 if not meta_names:
290 default_meta = getMetaServerBaseURL() # grab the meta from ini.xml
291 meta_names.append(default_meta) # add it to the return list
292 # print "Warning!!\nNo valid metaservers cached."
293 # print "Using meta from MetaServerBaseURL: " + default_meta + "\n"
294 # if we have more than one and want a random one
295 elif pick_random:
296 if META_DEBUG: print "choosing random meta from: " + str(meta_names)
297 i = int(uniform(0,len(meta_names)))
298 #meta = meta_names[i]
299 meta_names = [meta_names[i]]
300 if META_DEBUG: print "using: " + str(meta_names)
301 else:
302 if META_DEBUG: print "using all metas: " + str(meta_names)
303 return meta_names
304 except Exception,e:
305 print e
306 #print "using default meta server URI: " + default_url
307 metas = []
308 #metas.append(default_url)
309 return metas # return an empty list
310 else: # otherwise, use MetaServerBaseURL()
311 url = getMetaServerBaseURL()
312 meta_names.append(url)
313 return meta_names
314
315 def getMetaServerBaseURL():
316 # get meta server URL
317 url = "http://www.openrpg.com/openrpg_servers.php"
318 try:
319 component.get('validate').config_file("settings.xml","default_settings.xml") 207 component.get('validate').config_file("settings.xml","default_settings.xml")
320 ini = open(dir_struct["user"]+"settings.xml","r") 208 setting = parse(dir_struct["user"]+"settings.xml")
321 txt = ini.read() 209 tree = setting.getroot()
322 xml = component.get('xml') 210 node_list = tree.getiterator("MetaServers")
323 tree = xml.parseXml(txt)._get_documentElement() 211 if len(node_list) == 0:
324 ini.close() 212 component.get('frame').add_setting('Meta Servers')
325 node_list = tree.getElementsByTagName("MetaServerBaseURL") 213 setting = parse(dir_struct["user"]+"settings.xml")
326 if node_list: 214 metas = parse(dir_struct["user"]+'metaservers.xml').getroot()
327 url = node_list[0].getAttribute("value") 215 else:
328 # allow tree to be collected 216 meta = node_list[0].get("value")
329 try: tree.unlink() 217 metas = parse(dir_struct["user"]+meta).getroot()
330 except: pass 218 meta_list = metas.findall('meta')
331 219 return meta_list
332 except Exception,e: 220 except Exception,e: print e
333 print e 221 return meta_list
334 #print "using meta server URI: " + url
335 return url
336 222
337 """ 223 """
338 Beginning of Class registerThread 224 Beginning of Class registerThread
339 225
340 A Class to Manage Registration with the Meta2 226 A Class to Manage Registration with the Meta2
395 281
396 Also, if MetaPath is specified, then use that. Makes 282 Also, if MetaPath is specified, then use that. Makes
397 it easier to have multiple registerThreads going to keep the server registered 283 it easier to have multiple registerThreads going to keep the server registered
398 on multiple (compatible) Metas. 284 on multiple (compatible) Metas.
399 """ 285 """
400 if MetaPath == None: self.path = getMetaServerBaseURL() # Do this if no Meta specified 286 if MetaPath == None: self.path = getMetaServerList() # Do this if no Meta specified
401 else: self.path = MetaPath 287 else: self.path = MetaPath
402 288
403 def getIdAndCookie(self): 289 def getIdAndCookie(self):
404 return self.id, self.cookie 290 return self.id, self.cookie
405 291
468 try: 354 try:
469 self.rlock.acquire() 355 self.rlock.acquire()
470 if not self.isAlive(): # check to see if this thread is dead 356 if not self.isAlive(): # check to see if this thread is dead
471 return 1 # If so, return an error result 357 return 1 # If so, return an error result
472 # Do the actual unregistering here 358 # Do the actual unregistering here
473 data = urlencode( {"server_data[id]":self.id, 359 data = urlencode( { "server_data[id]":self.id,
474 "server_data[cookie]":self.cookie, 360 "server_data[cookie]":self.cookie,
475 "server_data[version]":PROTOCOL_VERSION, 361 "server_data[version]":PROTOCOL_VERSION,
476 "act":"unregister"} ) 362 "act":"unregister"} )
477 try: # this POSTS the request and returns the result 363 for path in getMetaServerList():
478 xml_dom = get_server_dom(data=data, path=self.path) 364 try: # this POSTS the request and returns the result
479 if xml_dom.get("errmsg"): 365 etreeEl = get_server_dom(data, path.get('url'))
480 print "Error durring unregistration: " + xml_dom.get("errmsg") 366 if etreeEl.get("errmsg") != None:
481 except: 367 print "Error durring unregistration: " + etreeEl.get("errmsg")
482 if META_DEBUG: print "Problem talking to Meta. Will go ahead and die, letting Meta remove us." 368 except Exception, e:
369 if META_DEBUG: print "Problem talking to Meta. Will go ahead and die, letting Meta remove us."
370 if META_DEBUG: print e
483 # If there's an error, echo it to the console 371 # If there's an error, echo it to the console
484 372
485 # No special handling is required. If the de-registration worked we're done. If 373 # No special handling is required. If the de-registration worked we're done. If
486 # not, then it's because we've already been removed or have a bad cookie. Either 374 # not, then it's because we've already been removed or have a bad cookie. Either
487 # way, we can't do anything else, so die. 375 # way, we can't do anything else, so die.
508 if not self.isAlive(): # check to see if this thread is dead 396 if not self.isAlive(): # check to see if this thread is dead
509 return 1 # If so, return an error result 397 return 1 # If so, return an error result
510 398
511 # Set the server's attibutes, if specified. 399 # Set the server's attibutes, if specified.
512 if name: self.name = name 400 if name: self.name = name
513 if num_users != None: self.num_users = num_users 401 if num_users != None:
402 try: self.num_users = len(num_users)
403 except: self.num_users = num_users; print num_users
404 else: self.num_users = 0
514 if realHostName: self.realHostName = realHostName 405 if realHostName: self.realHostName = realHostName
515 # build POST data 406 # build POST data
516 if self.realHostName: 407 if self.realHostName:
517 data = urlencode( {"server_data[id]":self.id, 408 data = urlencode( { "server_data[id]":self.id,
518 "server_data[cookie]":self.cookie, 409 "server_data[cookie]":self.cookie,
519 "server_data[name]":self.name, 410 "server_data[name]":self.name,
520 "server_data[port]":self.port, 411 "server_data[port]":self.port,
521 "server_data[version]":PROTOCOL_VERSION, 412 "server_data[version]":PROTOCOL_VERSION,
522 "server_data[num_users]":self.num_users, 413 "server_data[num_users]":self.num_users,
523 "act":"register", 414 "act":"register",
524 "server_data[address]": self.realHostName } ) 415 "server_data[address]": self.realHostName } )
525 else: 416 else:
526 if META_DEBUG: print "Letting meta server decide the hostname to list..." 417 if META_DEBUG: print "Letting meta server decide the hostname to list..."
527 data = urlencode( {"server_data[id]":self.id, 418 data = urlencode( { "server_data[id]":self.id,
528 "server_data[cookie]":self.cookie, 419 "server_data[cookie]":self.cookie,
529 "server_data[name]":self.name, 420 "server_data[name]":self.name,
530 "server_data[port]":self.port, 421 "server_data[port]":self.port,
531 "server_data[version]":PROTOCOL_VERSION, 422 "server_data[version]":PROTOCOL_VERSION,
532 "server_data[num_users]":self.num_users, 423 "server_data[num_users]":self.num_users,
533 "act":"register"} ) 424 "act":"register"} )
534 try: # this POSTS the request and returns the result 425 for path in getMetaServerList():
535 etreeEl = get_server_dom(data=data, path=self.path) 426 try: # this POSTS the request and returns the result
536 except: 427 etreeEl = get_server_dom(data, path.get('url'))
537 if META_DEBUG: print "Problem talking to server. Setting interval for retry ..." 428 except Exception, e:
538 if META_DEBUG: print data 429 if META_DEBUG: print "Problem talking to server. Setting interval for retry ..."
539 if META_DEBUG: print 430 if META_DEBUG: print data
540 self.interval = 0 431 if META_DEBUG: print e
541 """ 432 self.interval = 0
542 If we are in the registerThread thread, then setting interval to 0 433 """
543 will end up causing a retry in about 6 seconds (see self.run()) 434 If we are in the registerThread thread, then setting interval to 0
544 If we are in the main thread, then setting interval to 0 will do one 435 will end up causing a retry in about 6 seconds (see self.run())
545 of two things: 436 If we are in the main thread, then setting interval to 0 will do one
546 1) Do the same as if we were in the registerThread 437 of two things:
547 2) Cause the next, normally scheduled register() call to use the values 438 1) Do the same as if we were in the registerThread
548 provided in this call. 439 2) Cause the next, normally scheduled register() call to use the values
549 440 provided in this call.
550 Which case occurs depends on where the registerThread thread is when 441
551 the main thread calls register(). 442 Which case occurs depends on where the registerThread thread is when
552 """ 443 the main thread calls register().
553 return 0 # indicates that it was okay to call, not that no errors occurred 444 """
445 return 0 # indicates that it was okay to call, not that no errors occurred
554 446
555 # If there is a DOM returned .... 447 # If there is a DOM returned ....
556 if etreeEl: 448 if etreeEl != None:
557 # If there's an error, echo it to the console 449 # If there's an error, echo it to the console
558 if etreeEl.get("errmsg"): 450 print tostring(etreeEl)
451 if etreeEl.get("errmsg") != None:
559 print "Error durring registration: " + etreeEl.get("errmsg") 452 print "Error durring registration: " + etreeEl.get("errmsg")
560 if META_DEBUG: print data 453 if META_DEBUG: print data
561 if META_DEBUG: print 454 if META_DEBUG: print
562 """ 455 """
563 No special handling is required. If the registration worked, id, cookie, and interval 456 No special handling is required. If the registration worked, id, cookie, and interval
579 """ 472 """
580 try: 473 try:
581 self.interval = int(etreeEl.get("interval")) 474 self.interval = int(etreeEl.get("interval"))
582 self.id = etreeEl.get("id") 475 self.id = etreeEl.get("id")
583 self.cookie = etreeEl.get("cookie") 476 self.cookie = etreeEl.get("cookie")
584 if not etreeEl.get("errmsg"): updateMetaCache(xml_dom) 477 #if etreeEl.get("errmsg") == None: updateMetaCache(xml_dom)
585 except: 478 except Exception, e:
586 if META_DEBUG: print 479 if META_DEBUG: print
587 if META_DEBUG: print "OOPS! Is the Meta okay? It should be returning an id, cookie, and interval." 480 if META_DEBUG: print "OOPS! Is the Meta okay? It should be returning an id, cookie, and interval."
588 if META_DEBUG: print "Check to see what it really returned.\n" 481 if META_DEBUG: print "Check to see what it really returned.\n"
482 if META_DEBUG: print e
589 # Let xml_dom get garbage collected 483 # Let xml_dom get garbage collected
590 try: xml_dom.unlink() 484 try: xml_dom.unlink()
591 except: pass 485 except: pass
592 else: # else if no DOM is returned from get_server_dom() 486 else: # else if no DOM is returned from get_server_dom()
593 print "Error - no DOM constructed from Meta message!" 487 print "Error - no DOM constructed from Meta message!"