diff orpg/networking/meta_server_lib.py @ 66:c54768cffbd4 ornery-dev

Traipse Dev 'OpenRPG' {090818-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: *Unstable* This is the first wave of Code Refinement updates. Includes new material from Core Beta; new debugger material (partially implemented), beginnings of switch to etree, TerminalWriter, and a little more. open_rpg has been renamed to component; functioning now as component.get(), component.add(), component.delete(). This version has known bugs, specifically with the gametree and nodes. I think the XML files where not removed during testing of Core and switching back.
author sirebral
date Tue, 18 Aug 2009 06:33:37 -0500
parents 4385a7d0efd1
children 449a8900f9ac
line wrap: on
line diff
--- a/orpg/networking/meta_server_lib.py	Mon Aug 17 06:56:31 2009 -0500
+++ b/orpg/networking/meta_server_lib.py	Tue Aug 18 06:33:37 2009 -0500
@@ -34,9 +34,8 @@
 __version__ = "$Id: meta_server_lib.py,v 1.40 2007/04/04 01:18:42 digitalxero Exp $"
 
 from orpg.orpg_version import PROTOCOL_VERSION
-from orpg.orpg_xml import *
-import orpg.dirpath
-import orpg.tools.validate
+from orpg.orpgCore import *
+from orpg.dirpath import dir_struct
 import urllib
 import orpg.minidom
 from threading import *
@@ -79,7 +78,8 @@
         print data
         print
     # build dom
-    xml_dom = parseXml(data)
+    xml = component.get('xml')
+    xml_dom = xml.parseXml(data)
     xml_dom = xml_dom._get_documentElement()
     return xml_dom
 
@@ -198,17 +198,13 @@
 
                 # set them from current node
 
-                if not n.hasAttribute('name'):
-                    n.setAttribute('name','NO_NAME_GIVEN')
+                if not n.hasAttribute('name'): n.setAttribute('name','NO_NAME_GIVEN')
                 name = n.getAttribute('name')
-                if not n.hasAttribute('num_users'):
-                    n.setAttribute('num_users','N/A')
+                if not n.hasAttribute('num_users'): n.setAttribute('num_users','N/A')
                 num_users = n.getAttribute('num_users')
-                if not n.hasAttribute('address'):
-                    n.setAttribute('address','NO_ADDRESS_GIVEN')
+                if not n.hasAttribute('address'): n.setAttribute('address','NO_ADDRESS_GIVEN')
                 address = n.getAttribute('address')
-                if not n.hasAttribute('port'):
-                    n.setAttribute('port','6774')
+                if not n.hasAttribute('port'): n.setAttribute('port','6774')
                 port = n.getAttribute('port')
                 n.setAttribute('meta',meta)
                 end_point = str(address) + ":" + str(port)
@@ -257,7 +253,7 @@
         if META_DEBUG: print "  Meta List ("+str(len(metas))+" servers)"
         try:
             metacache_lock.acquire()
-            ini = open(orpg.dirpath.dir_struct["user"]+"metaservers.cache","w")
+            ini = open(dir_struct["user"]+"metaservers.cache","w")
             for meta in metas:
                 if META_DEBUG: print "   Writing: "+str(meta.getAttribute('path'))
                 ini.write(str(meta.getAttribute('path')) + " " + str(meta.getAttribute('versions')) + "\n")
@@ -273,8 +269,8 @@
         try:
             metacache_lock.acquire()
             #  Read in the metas
-            orpg.tools.validate.Validate().config_file("metaservers.cache","metaservers.cache")
-            ini = open(orpg.dirpath.dir_struct["user"]+"metaservers.cache","r")
+            component.get('validate').config_file("metaservers.cache","metaservers.cache")
+            ini = open(dir_struct["user"]+"metaservers.cache","r")
             metas = ini.readlines()
             ini.close()
             return metas
@@ -357,10 +353,11 @@
     # get meta server URL
     url = "http://www.openrpg.com/openrpg_servers.php"
     try:
-        orpg.tools.validate.Validate().config_file("settings.xml","default_settings.xml")
-        ini = open(orpg.dirpath.dir_struct["user"]+"settings.xml","r")
+        component.get('validate').config_file("settings.xml","default_settings.xml")
+        ini = open(dir_struct["user"]+"settings.xml","r")
         txt = ini.read()
-        tree = parseXml(txt)._get_documentElement()
+        xml = component.get('xml')
+        tree = xml.parseXml(txt)._get_documentElement()
         ini.close()
         node_list = tree.getElementsByTagName("MetaServerBaseURL")
         if node_list: