X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Frspec.py;h=572d660055478a9ff28e621001c96b4a23f11496;hb=db091e73c33c373b7f6c2c96bd2caf6a2acf0178;hp=c56d38209f15b70e05f2fc9309aea3a5afb546d3;hpb=22b32a6c92c0d780f9847d1e2787f8794b82826b;p=sfa.git diff --git a/sfa/util/rspec.py b/sfa/util/rspec.py index c56d3820..572d6600 100644 --- a/sfa/util/rspec.py +++ b/sfa/util/rspec.py @@ -1,44 +1,13 @@ -### $Id$ -### $URL$ - import sys import pprint import os +from StringIO import StringIO +from types import StringTypes, ListType import httplib from xml.dom import minidom -from types import StringTypes, ListType from lxml import etree -from StringIO import StringIO - -def merge_rspecs(rspecs): - """ - Merge merge a set of RSpecs into 1 RSpec, and return the result. - rspecs must be a valid RSpec string or list of rspec strings. - """ - if not rspecs or not isinstance(rspecs, list): - return rspecs - - rspec = None - for tmp_rspec in rspecs: - try: - tree = etree.parse(StringIO(tmp_rspec)) - except etree.XMLSyntaxError: - # consider failing silently here - message = str(agg_rspec) + ": " + str(sys.exc_info()[1]) - raise InvalidRSpec(message) - - root = tree.getroot() - if root.get("type") in ["SFA"]: - if rspec == None: - rspec = root - else: - for network in root.iterfind("./network"): - rspec.append(deepcopy(network)) - for request in root.iterfind("./request"): - rspec.append(deepcopy(request)) - return etree.tostring(rspec, xml_declaration=True, pretty_print=True) - +from sfa.util.sfalogging import info_logger class RSpec: @@ -263,15 +232,14 @@ class RSpec: except Exception, e: # logging.debug("%s: web file not found" % xsdURI) # logging.debug("Using local file %s" % self.xsd") - print e - print "Can't find %s on the web. Continuing." % xsdURI + info_logger.log_exc("rspec.parseXSD: can't find %s on the web. Continuing." % xsdURI) if not schemaDom: if os.path.exists(xsdURI): # logging.debug("using local copy.") - print "Using local %s" % xsdURI + info_logger.debug("rspec.parseXSD: Using local %s" % xsdURI) schemaDom = minidom.parse(xsdURI) else: - raise Exception("Can't find xsd locally") + raise Exception("rspec.parseXSD: can't find xsd locally") self.schemaDict = self.toDict(schemaDom.childNodes[0])