comparison orpg/networking/meta_server_lib.py @ 236:9230a33defd9 beta

Traipse Beta 'OpenRPG' {100616-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 (Closing/Closed) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order New to Server GUI, can now clear log Updates: Update to Warhammer PC Sheet. Rollers set as macros. Should work with little maintanence. Update to Browser Server window. Display rooms with ' " & cleaner Update to Server. Handles ' " & cleaner. 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 Fix to Single and Double quotes in Whiteboard text Fix to Background images not showing when using the Image Server Fix to Duplicate chat names appearing Fix to Server GUI's logging output Fix to FNB.COLORFUL_TABS bug.
author sirebral
date Wed, 16 Jun 2010 03:06:20 -0500
parents 13054be69834
children b44dad398833
comparison
equal deleted inserted replaced
226:b29454610f36 236:9230a33defd9
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
40 40
41 import urllib, time, sys, traceback, re 41 import urllib, time, sys, traceback, re
42 42
43 from threading import * 43 from threading import *
44 from random import uniform 44 from random import uniform
45 import urllib2
45 from urllib import urlopen, urlencode 46 from urllib import urlopen, urlencode
46 from orpg.tools.orpg_log import debug 47 from orpg.tools.orpg_log import debug
47 48
48 from xml.etree.ElementTree import Element, fromstring 49 from xml.etree.ElementTree import Element, fromstring, parse, tostring
49 metacache_lock = RLock() 50 metacache_lock = RLock()
50 51
51 def get_server_dom(data=None,path=None, string=False): 52 def get_server_dom(data=None, path=None, string=False):
52 # post data at server and get the resulting DOM 53 if path[len(path)-1] != "/": path += '/'
53 if path == None:
54 # get meta server URI
55 path = getMetaServerBaseURL()
56 54
57 # POST the data 55 # POST the data
58 if META_DEBUG: 56 if META_DEBUG:
59 print 57 print
60 print "Sending the following POST info to Meta at " + path + ":" 58 print "Sending the following POST info to Meta at " + path + ":"
61 print "==========================================" 59 print "=========================================="
62 print data 60 print data
63 print 61 print
64 file = urlopen(path, data) 62 #recvdata = urllib2.Request(path, data)
65 data = file.read() 63 response = urllib2.urlopen(path, data)
66 file.close() 64 data = response.read()
67 65
68 # 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
69 p = re.compile('(<servers>.*?</servers>)',re.DOTALL|re.IGNORECASE) 67 p = re.compile('(<servers>.*?</servers>)',re.DOTALL|re.IGNORECASE)
70 mo = p.search(data) 68 mo = p.search(data)
71 if mo: data = mo.group(0) 69 if mo: data = mo.group(0)
75 print "Got this string from the Meta at " + path + ":" 73 print "Got this string from the Meta at " + path + ":"
76 print "===============================================" 74 print "==============================================="
77 print data 75 print data
78 print 76 print
79 # build dom 77 # build dom
80 etreeEl = data 78 if string: return data
81 if not string: return fromstring(etreeEl) 79 else: return fromstring(data)
82 else: return etreeEl
83 80
84 def post_server_data(name, realHostName=None): 81 def post_server_data(name, realHostName=None):
85 if realHostName: data = urlencode({"server_data[name]":name, 82 if realHostName: data = urlencode({"server_data[name]":name,
86 "server_data[version]":PROTOCOL_VERSION, 83 "server_data[version]":PROTOCOL_VERSION,
87 "act":"new", 84 "act":"new",
88 "REMOTE_ADDR": realHostName }) 85 "REMOTE_ADDR": realHostName })
89 # print "Letting meta server decide the hostname to list..." 86 # print "Letting meta server decide the hostname to list..."
90 else: data = urlencode({"server_data[name]":name, 87 else: data = urlencode({"server_data[name]":name,
91 "server_data[version]":PROTOCOL_VERSION, 88 "server_data[version]":PROTOCOL_VERSION,
92 "act":"new"}) 89 "act":"new"})
93 path = component.get('settings').get('MetaServerBaseURL') #getMetaServerBaseURL() 90 path = component.get('settings').get('MetaServerBaseURL') #getMetaServerList()
94 etreeEl = get_server_dom(data, path) 91 etreeEl = get_server_dom(data, path)
95 return int(etreeEl.get('id')) 92 return int(etreeEl.get('id'))
96 93
97 def post_failed_connection(id,meta=None,address=None,port=None): 94 def post_failed_connection(id,meta=None,address=None,port=None):
98 # 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
109 return int(etreeEl.get("return")) 106 return int(etreeEl.get("return"))
110 107
111 def byStartAttribute(first, second): 108 def byStartAttribute(first, second):
112 # 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
113 # Ensure there is something to sort with for each 110 # Ensure there is something to sort with for each
114
115 first_start = int(first.get('start')) or 0 111 first_start = int(first.get('start')) or 0
116 second_start = int(second.get('start')) or 0 112 second_start = int(second.get('start')) or 0
117
118 # Return the result of the cmp function on the two strings 113 # Return the result of the cmp function on the two strings
119 return cmp(first_start, second_start) 114 return cmp(first_start, second_start)
120 115
121 def byNameAttribute(first, second): 116 def byNameAttribute(first, second):
122 # 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
123 # Ensure there is something to sort with for each 118 # Ensure there is something to sort with for each
124
125 first_name = first.get('name') or '' 119 first_name = first.get('name') or ''
126 second_name = second.get('name') or '' 120 second_name = second.get('name') or ''
127
128 # Return the result of the cmp function on the two strings 121 # Return the result of the cmp function on the two strings
129 return cmp(first_name,second_name) 122 return cmp(first_name,second_name)
130 123
131 124
132 def get_server_list(versions = None, sort_by="start"): 125 def get_server_list(versions=None, sort_by="start"):
133 data = urlencode({"version":PROTOCOL_VERSION,"ports":"%"}) 126 data = urlencode({"version":PROTOCOL_VERSION,"ports":"%"})
134 all_metas = getMetaServers(versions, 1) # get the list of metas 127 #all_metas = getMetaServers(versions, False) # get the list of metas
135 base_meta = getMetaServerBaseURL() 128 meta_list = getMetaServerList()
136
137 #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
138 # 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
139 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
140 132
141 for meta in all_metas: # check all of the metas 133 for meta in meta_list: # check all of the metas
142 #get the server's xml from the current meta 134 #get the server's xml from the current meta
143 bad_meta = 0 135 bad_meta = 0
144 #print "Getting server list from " + meta + "..." 136 #print "Getting server list from " + meta + "..."
145 try: xml_dom = get_server_dom(data=data, path=meta) 137 try: xml_dom = get_server_dom(data, meta.get('url'))
146 except: bad_meta = 1 #print "Trouble getting servers from " + meta + "..." 138 except: bad_meta = 1; print "Trouble getting servers from " + meta.get('url') + "..."
147 if bad_meta: continue 139 if bad_meta: continue
148 if base_meta == meta: updateMetaCache(xml_dom) #print "This is our base meta: " + meta
149 node_list = xml_dom.findall('server') 140 node_list = xml_dom.findall('server')
150 if len(node_list): # if there are entries in the node list 141 if len(node_list):
151 # otherwise, just loop to next meta
152
153 # for each node found, we're going to check the nodes from prior
154 # metas in the list. If a match is found, then use the new values.
155 for n in node_list: 142 for n in node_list:
156 # set them from current node
157 if not n.get('name'): n.set('name','NO_NAME_GIVEN') 143 if not n.get('name'): n.set('name','NO_NAME_GIVEN')
158 name = n.get('name') 144 name = n.get('name')
159 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')
160 num_users = n.get('num_users') 146 num_users = n.get('num_users')
161 if not n.get('address'): n.set('address','NO_ADDRESS_GIVEN') 147 if not n.get('address'): n.set('address','NO_ADDRESS_GIVEN')
163 if not n.get('port'): n.set('port','6774') 149 if not n.get('port'): n.set('port','6774')
164 port = n.get('port') 150 port = n.get('port')
165 n.set('meta',meta) 151 n.set('meta',meta)
166 end_point = str(address) + ":" + str(port) 152 end_point = str(address) + ":" + str(port)
167 if return_hash.has_key(end_point): 153 if return_hash.has_key(end_point):
154 print end_point
155 print n
156
168 if META_DEBUG: print "Replacing duplicate server entry at " + end_point 157 if META_DEBUG: print "Replacing duplicate server entry at " + end_point
169 return_hash[end_point] = n 158 return_hash[end_point] = n
170
171 # At this point, we have an amalgamated list of servers
172 # Now, we have to construct a new DOM to pass back.
173
174 # Create a servers element
175 server_list = Element('servers') 159 server_list = Element('servers')
176
177 # get the nodes stored in return_hash
178 sort_list = return_hash.values() 160 sort_list = return_hash.values()
179
180 # sort them by their name attribute. Uses byNameAttribute()
181 # defined above as a comparison function
182 if sort_by == "start": sort_list.sort(byStartAttribute) 161 if sort_by == "start": sort_list.sort(byStartAttribute)
183 elif sort_by == "name": sort_list.sort(byNameAttribute) 162 elif sort_by == "name": sort_list.sort(byNameAttribute)
184
185 # Add each node to the DOM
186 for n in sort_list: server_list.append(n) 163 for n in sort_list: server_list.append(n)
187 return server_list 164 return server_list
188 165
189 ## List Format: 166 ## List Format:
190 ## <servers> 167 ## <servers>
214 metacache_lock.release() 191 metacache_lock.release()
215 except Exception, e: 192 except Exception, e:
216 if META_DEBUG: traceback.print_exc() 193 if META_DEBUG: traceback.print_exc()
217 print "Meta Server Lib: UpdateMetaCache(): " + str(e) 194 print "Meta Server Lib: UpdateMetaCache(): " + str(e)
218 195
219 def getRawMetaList(path=None): 196
220 ### Alpha ### 197 def getMetaServerList():
221 """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
222 if path != None: 199 meta_list = fromstring("""
223 metas = [] 200 <metaservers>
224 data = urlencode({"version":PROTOCOL_VERSION,"ports":"%"}) 201 <meta url="http://orpgmeta.appspot.com" versions="1 2" />
225 xml_dom = get_server_dom(data, path) 202 <meta url="http://traipsemeta.madmathlabs.info" versions="1 2" />
226 node_list = fromstring(xml_dom).findall('meta_server') 203 </metaservers>"""
227 if len(node_list): 204 )
228 for n in node_list:
229 metas.append(n.get('path'))
230 return metas
231 try: 205 try:
232 try: 206 component.get('validate').config_file("metaservers.xml","default_metaservers.xml")
233 metacache_lock.acquire()
234 # Read in the metas
235 validate.config_file("metaservers.cache","metaservers.cache")
236 ini = open(dir_struct["user"]+"metaservers.cache","r")
237 metas = ini.readlines()
238 ini.close()
239 return metas
240 finally:
241 metacache_lock.release()
242 except Exception, e:
243 if META_DEBUG: traceback.print_exc()
244 print "Meta Server Lib: getRawMetaList(): " + str(e)
245 return []
246
247 def getMetaServers(versions = None, pick_random=0):
248 """
249 get meta server URLs as a list
250 versions is a list of acceptable version numbers.
251 A False truth value will use getMetaServerBaseURL()
252 set a default if we have weird reading problems
253 default_url = "http://www.openrpg.com/openrpg_servers.php"
254 """
255
256 ### Pre Alpha Design ###
257 """ 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."""
258 meta_names = []
259 if(versions): # If versions are supplied, then look in metaservers.conf
260 try:
261 """
262 read in the metas from file
263 format of file is one meta entry per line
264 each entry will be the meta url, followed by one or more version numbers that it
265 handle. Generally, this will be either a 1 for the original Meta format, or
266 2 for the new one.
267 """
268 # Read in the metas
269 #Adding a path object will attempt to look for a meta_network.
270 metas = getRawMetaList()
271
272 # go through each one to check if it should be returned, based on the
273 # version numbers allowed.
274 for meta in metas:
275 # split the line on whitespace
276 # obviously, your meta servers urls shouldn't contain whitespace. duh.
277 words = meta.split()
278 success = 0 # init success flag for version check
279 for version in versions: # run through each allowed version from caller
280 if version in words[1:]: # if the allowed version token was found
281 success += 1 # then increment the success indicator
282 if success: # if the meta entry is acceptable to the caller
283 meta_names.append(words[0]) # add the entry
284 if META_DEBUG: print "adding metaserver " + meta
285
286 # at this point, we should have at least one name from the cache. If not ...
287 if not meta_names:
288 default_meta = getMetaServerBaseURL() # grab the meta from ini.xml
289 meta_names.append(default_meta) # add it to the return list
290 # print "Warning!!\nNo valid metaservers cached."
291 # print "Using meta from MetaServerBaseURL: " + default_meta + "\n"
292 # if we have more than one and want a random one
293 elif pick_random:
294 if META_DEBUG: print "choosing random meta from: " + str(meta_names)
295 i = int(uniform(0,len(meta_names)))
296 #meta = meta_names[i]
297 meta_names = [meta_names[i]]
298 if META_DEBUG: print "using: " + str(meta_names)
299 else:
300 if META_DEBUG: print "using all metas: " + str(meta_names)
301 return meta_names
302 except Exception,e:
303 print e
304 #print "using default meta server URI: " + default_url
305 metas = []
306 #metas.append(default_url)
307 return metas # return an empty list
308 else: # otherwise, use MetaServerBaseURL()
309 url = getMetaServerBaseURL()
310 meta_names.append(url)
311 return meta_names
312
313 def getMetaServerBaseURL():
314 # get meta server URL
315 url = "http://orpgmeta.appspot.com/"
316 try:
317 component.get('validate').config_file("settings.xml","default_settings.xml") 207 component.get('validate').config_file("settings.xml","default_settings.xml")
318 ini = open(dir_struct["user"]+"settings.xml","r") 208 setting = parse(dir_struct["user"]+"settings.xml")
319 txt = ini.read() 209 tree = setting.getroot()
320 xml = component.get('xml') 210 node_list = tree.getiterator("MetaServers")
321 tree = xml.parseXml(txt)._get_documentElement() 211 if len(node_list) == 0:
322 ini.close() 212 component.get('frame').add_setting('Meta Servers')
323 node_list = tree.getElementsByTagName("MetaServerBaseURL") 213 setting = parse(dir_struct["user"]+"settings.xml")
324 if node_list: 214 metas = parse(dir_struct["user"]+'metaservers.xml').getroot()
325 url = node_list[0].getAttribute("value") 215 else:
326 print url 216 meta = node_list[0].get("value")
327 # allow tree to be collected 217 metas = parse(dir_struct["user"]+meta).getroot()
328 try: tree.unlink() 218 meta_list = metas.findall('meta')
329 except: pass 219 return meta_list
330 220 except Exception,e: print e
331 except Exception,e: 221 return meta_list
332 print e
333 #print "using meta server URI: " + url
334 return url
335 222
336 """ 223 """
337 Beginning of Class registerThread 224 Beginning of Class registerThread
338 225
339 A Class to Manage Registration with the Meta2 226 A Class to Manage Registration with the Meta2
384 self.interval = 0 # interval returned from Meta. Is how often to 271 self.interval = 0 # interval returned from Meta. Is how often to
385 # re-register, in minutes. 272 # re-register, in minutes.
386 self.destroy = 0 # Used to flag that this thread should die 273 self.destroy = 0 # Used to flag that this thread should die
387 self.port = str(port) 274 self.port = str(port)
388 self.register_callback = register_callback # set a method to call to report result of register 275 self.register_callback = register_callback # set a method to call to report result of register
276 self.IdAttempts = 0
389 """ 277 """
390 This thread will communicate with one and only one 278 This thread will communicate with one and only one
391 Meta. If the Meta in ini.xml is changed after 279 Meta. If the Meta in ini.xml is changed after
392 instantiation, then this instance must be 280 instantiation, then this instance must be
393 unregistered and a new instance instantiated. 281 unregistered and a new instance instantiated.
394 282
395 Also, if MetaPath is specified, then use that. Makes 283 Also, if MetaPath is specified, then use that. Makes
396 it easier to have multiple registerThreads going to keep the server registered 284 it easier to have multiple registerThreads going to keep the server registered
397 on multiple (compatible) Metas. 285 on multiple (compatible) Metas.
398 """ 286 """
399 if MetaPath == None: self.path = getMetaServerBaseURL() # Do this if no Meta specified 287 if MetaPath == None: self.path = getMetaServerList() # Do this if no Meta specified
400 else: self.path = MetaPath 288 else: self.path = MetaPath
401 289
402 def getIdAndCookie(self): 290 def getIdAndCookie(self):
403 return self.id, self.cookie 291 return self.id, self.cookie
404 292
467 try: 355 try:
468 self.rlock.acquire() 356 self.rlock.acquire()
469 if not self.isAlive(): # check to see if this thread is dead 357 if not self.isAlive(): # check to see if this thread is dead
470 return 1 # If so, return an error result 358 return 1 # If so, return an error result
471 # Do the actual unregistering here 359 # Do the actual unregistering here
472 data = urlencode( {"server_data[id]":self.id, 360 data = urlencode( { "server_data[id]":self.id,
473 "server_data[cookie]":self.cookie, 361 "server_data[cookie]":self.cookie,
474 "server_data[version]":PROTOCOL_VERSION, 362 "server_data[version]":PROTOCOL_VERSION,
475 "act":"unregister"} ) 363 "act":"unregister"} )
476 try: # this POSTS the request and returns the result 364 for path in getMetaServerList():
477 xml_dom = get_server_dom(data=data, path=self.path) 365 try: # this POSTS the request and returns the result
478 if xml_dom.get("errmsg"): 366 etreeEl = get_server_dom(data, path.get('url'))
479 print "Error durring unregistration: " + xml_dom.get("errmsg") 367 if etreeEl.get("errmsg") != None:
480 except: 368 print "Error durring unregistration: " + etreeEl.get("errmsg")
481 if META_DEBUG: print "Problem talking to Meta. Will go ahead and die, letting Meta remove us." 369 except Exception, e:
370 if META_DEBUG: print "Problem talking to Meta. Will go ahead and die, letting Meta remove us."
371 if META_DEBUG: print e
482 # If there's an error, echo it to the console 372 # If there's an error, echo it to the console
483 373
484 # No special handling is required. If the de-registration worked we're done. If 374 # No special handling is required. If the de-registration worked we're done. If
485 # not, then it's because we've already been removed or have a bad cookie. Either 375 # not, then it's because we've already been removed or have a bad cookie. Either
486 # way, we can't do anything else, so die. 376 # way, we can't do anything else, so die.
507 if not self.isAlive(): # check to see if this thread is dead 397 if not self.isAlive(): # check to see if this thread is dead
508 return 1 # If so, return an error result 398 return 1 # If so, return an error result
509 399
510 # Set the server's attibutes, if specified. 400 # Set the server's attibutes, if specified.
511 if name: self.name = name 401 if name: self.name = name
512 if num_users != None: self.num_users = num_users 402 if num_users != None:
403 try: self.num_users = len(num_users)
404 except: self.num_users = num_users
405 else: self.num_users = 0
513 if realHostName: self.realHostName = realHostName 406 if realHostName: self.realHostName = realHostName
514 # build POST data 407 # build POST data
515 if self.realHostName: 408 if self.realHostName:
516 data = urlencode( {"server_data[id]":self.id, 409 data = urlencode( { "server_data[id]":self.id,
517 "server_data[cookie]":self.cookie, 410 "server_data[cookie]":self.cookie,
518 "server_data[name]":self.name, 411 "server_data[name]":self.name,
519 "server_data[port]":self.port, 412 "server_data[port]":self.port,
520 "server_data[version]":PROTOCOL_VERSION, 413 "server_data[version]":PROTOCOL_VERSION,
521 "server_data[num_users]":self.num_users, 414 "server_data[num_users]":self.num_users,
522 "act":"register", 415 "act":"register",
523 "server_data[address]": self.realHostName } ) 416 "server_data[address]": self.realHostName } )
524 else: 417 else:
525 if META_DEBUG: print "Letting meta server decide the hostname to list..." 418 if META_DEBUG: print "Letting meta server decide the hostname to list..."
526 data = urlencode( {"server_data[id]":self.id, 419 data = urlencode( { "server_data[id]":self.id,
527 "server_data[cookie]":self.cookie, 420 "server_data[cookie]":self.cookie,
528 "server_data[name]":self.name, 421 "server_data[name]":self.name,
529 "server_data[port]":self.port, 422 "server_data[port]":self.port,
530 "server_data[version]":PROTOCOL_VERSION, 423 "server_data[version]":PROTOCOL_VERSION,
531 "server_data[num_users]":self.num_users, 424 "server_data[num_users]":self.num_users,
532 "act":"register"} ) 425 "act":"register"} )
533 try: # this POSTS the request and returns the result 426 try: # this POSTS the request and returns the result
534 etreeEl = get_server_dom(data=data, path=self.path) 427 etreeEl = get_server_dom(data, self.path)
535 except: 428 except Exception, e:
536 if META_DEBUG: print "Problem talking to server. Setting interval for retry ..." 429 if META_DEBUG: print "Problem talking to server. Setting interval for retry ..."
537 if META_DEBUG: print data 430 if META_DEBUG: print data
538 if META_DEBUG: print 431 if META_DEBUG: print e
539 self.interval = 0 432 self.interval = 0
540 """ 433 """
541 If we are in the registerThread thread, then setting interval to 0 434 If we are in the registerThread thread, then setting interval to 0
542 will end up causing a retry in about 6 seconds (see self.run()) 435 will end up causing a retry in about 6 seconds (see self.run())
543 If we are in the main thread, then setting interval to 0 will do one 436 If we are in the main thread, then setting interval to 0 will do one
550 the main thread calls register(). 443 the main thread calls register().
551 """ 444 """
552 return 0 # indicates that it was okay to call, not that no errors occurred 445 return 0 # indicates that it was okay to call, not that no errors occurred
553 446
554 # If there is a DOM returned .... 447 # If there is a DOM returned ....
555 if etreeEl: 448 if etreeEl != None:
556 # If there's an error, echo it to the console 449 # If there's an error, echo it to the console
557 if etreeEl.get("errmsg"): 450 if etreeEl.get("errmsg") != None:
558 print "Error durring registration: " + etreeEl.get("errmsg") 451 print "Error durring registration at: " +path.get('url')+ " Error: " +etreeEl.get("errmsg")
559 if META_DEBUG: print data 452 if META_DEBUG: print data
560 if META_DEBUG: print 453 if META_DEBUG: print
561 """ 454 """
562 No special handling is required. If the registration worked, id, cookie, and interval 455 No special handling is required. If the registration worked, id, cookie, and interval
563 can be stored and used for the next time. 456 can be stored and used for the next time.
578 """ 471 """
579 try: 472 try:
580 self.interval = int(etreeEl.get("interval")) 473 self.interval = int(etreeEl.get("interval"))
581 self.id = etreeEl.get("id") 474 self.id = etreeEl.get("id")
582 self.cookie = etreeEl.get("cookie") 475 self.cookie = etreeEl.get("cookie")
583 if not etreeEl.get("errmsg"): updateMetaCache(xml_dom) 476 #if etreeEl.get("errmsg") == None: updateMetaCache(xml_dom)
584 except: 477 except Exception, e:
585 if META_DEBUG: print 478 if META_DEBUG: print
586 if META_DEBUG: print "OOPS! Is the Meta okay? It should be returning an id, cookie, and interval." 479 if META_DEBUG: print "OOPS! Is the Meta okay? It should be returning an id, cookie, and interval."
587 if META_DEBUG: print "Check to see what it really returned.\n" 480 if META_DEBUG: print "Check to see what it really returned.\n"
481 if META_DEBUG: print e
588 # Let xml_dom get garbage collected 482 # Let xml_dom get garbage collected
589 try: xml_dom.unlink() 483 try: xml_dom.unlink()
590 except: pass 484 except: pass
591 else: # else if no DOM is returned from get_server_dom() 485 else: # else if no DOM is returned from get_server_dom()
592 print "Error - no DOM constructed from Meta message!" 486 print "Error - no DOM constructed from Meta message!"