comparison orpg/networking/meta_server_lib.py @ 151:06f10429eedc alpha

Traipse Alpha 'OpenRPG' {091125-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 (See documentation for usage) Mercurial's hgweb folder is ported to upmana Pretty important update that can help remove thousands of dead children from your gametree. Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! New Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops return error instead of freezing the software! New Syntax added for custom PC sheets Tip of the Day added, from Core and community Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix.
author sirebral
date Wed, 25 Nov 2009 06:15:49 -0600
parents 8827271fbe1b
children b633f4c64aae 81d0bfd5e800
comparison
equal deleted inserted replaced
149:c2caca988a11 151:06f10429eedc
50 50
51 metacache_lock = RLock() 51 metacache_lock = RLock()
52 52
53 def get_server_dom(data=None,path=None, string=False): 53 def get_server_dom(data=None,path=None, string=False):
54 # post data at server and get the resulting DOM 54 # post data at server and get the resulting DOM
55 #debug()
56 if path == None: 55 if path == None:
57 # get meta server URI 56 # get meta server URI
58 path = getMetaServerBaseURL() 57 path = getMetaServerBaseURL()
59 58
60 # POST the data 59 # POST the data
83 etreeEl = data 82 etreeEl = data
84 if not string: return fromstring(etreeEl) 83 if not string: return fromstring(etreeEl)
85 else: return etreeEl 84 else: return etreeEl
86 85
87 def post_server_data(name, realHostName=None): 86 def post_server_data(name, realHostName=None):
88 #debug()
89 if realHostName: data = urlencode({"server_data[name]":name, 87 if realHostName: data = urlencode({"server_data[name]":name,
90 "server_data[version]":PROTOCOL_VERSION, 88 "server_data[version]":PROTOCOL_VERSION,
91 "act":"new", 89 "act":"new",
92 "REMOTE_ADDR": realHostName }) 90 "REMOTE_ADDR": realHostName })
93 # print "Letting meta server decide the hostname to list..." 91 # print "Letting meta server decide the hostname to list..."
97 path = component.get('settings').get('MetaServerBaseURL') #getMetaServerBaseURL() 95 path = component.get('settings').get('MetaServerBaseURL') #getMetaServerBaseURL()
98 etreeEl = get_server_dom(data, path) 96 etreeEl = get_server_dom(data, path)
99 return int(etreeEl.get('id')) 97 return int(etreeEl.get('id'))
100 98
101 def post_failed_connection(id,meta=None,address=None,port=None): 99 def post_failed_connection(id,meta=None,address=None,port=None):
102 #debug((meta, address, port))
103 # For now, turning this off. This needs to be re-vamped for 100 # For now, turning this off. This needs to be re-vamped for
104 # handling multiple Metas. 101 # handling multiple Metas.
105 return 0 102 return 0
106 #data = urlencode({"id":id,"act":"failed"}); 103 #data = urlencode({"id":id,"act":"failed"});
107 #xml_dom = get_server_dom(data) 104 #xml_dom = get_server_dom(data)
108 #ret_val = int(xml_dom.getAttribute("return")) 105 #ret_val = int(xml_dom.getAttribute("return"))
109 #return ret_val 106 #return ret_val
110 107
111 def remove_server(id): 108 def remove_server(id):
112 #debug(id)
113 data = urlencode({"id":id,"act":"del"}); 109 data = urlencode({"id":id,"act":"del"});
114 etreeEl = get_server_dom(data) 110 etreeEl = get_server_dom(data)
115 return int(etreeEl.get("return")) 111 return int(etreeEl.get("return"))
116 112
117 def byStartAttribute(first, second): 113 def byStartAttribute(first, second):
495 except: pass 491 except: pass
496 return 0 492 return 0
497 finally: self.rlock.release() 493 finally: self.rlock.release()
498 494
499 def register(self, name=None, realHostName=None, num_users=None): 495 def register(self, name=None, realHostName=None, num_users=None):
500 #debug((name, realHostName, num_users))
501 """ 496 """
502 Designed to handle the registration, both new and 497 Designed to handle the registration, both new and
503 repeated. 498 repeated.
504 499
505 It is intended to be called once every interval 500 It is intended to be called once every interval
536 "server_data[version]":PROTOCOL_VERSION, 531 "server_data[version]":PROTOCOL_VERSION,
537 "server_data[num_users]":self.num_users, 532 "server_data[num_users]":self.num_users,
538 "act":"register"} ) 533 "act":"register"} )
539 try: # this POSTS the request and returns the result 534 try: # this POSTS the request and returns the result
540 etreeEl = get_server_dom(data=data, path=self.path) 535 etreeEl = get_server_dom(data=data, path=self.path)
541 #debug(etreeEl)
542 except: 536 except:
543 if META_DEBUG: print "Problem talking to server. Setting interval for retry ..." 537 if META_DEBUG: print "Problem talking to server. Setting interval for retry ..."
544 if META_DEBUG: print data 538 if META_DEBUG: print data
545 if META_DEBUG: print 539 if META_DEBUG: print
546 self.interval = 0 540 self.interval = 0
558 """ 552 """
559 return 0 # indicates that it was okay to call, not that no errors occurred 553 return 0 # indicates that it was okay to call, not that no errors occurred
560 554
561 # If there is a DOM returned .... 555 # If there is a DOM returned ....
562 if etreeEl: 556 if etreeEl:
563 #debug(etreeEl)
564 # If there's an error, echo it to the console 557 # If there's an error, echo it to the console
565 if etreeEl.get("errmsg"): 558 if etreeEl.get("errmsg"):
566 print "Error durring registration: " + etreeEl.get("errmsg") 559 print "Error durring registration: " + etreeEl.get("errmsg")
567 if META_DEBUG: print data 560 if META_DEBUG: print data
568 if META_DEBUG: print 561 if META_DEBUG: print