ConfigTreeNode.py
changeset 1332 ac7d39f4e376
parent 1330 96b242e4c59d
child 1511 91538d0c242c
equal deleted inserted replaced
1331:38c5de794e62 1332:ac7d39f4e376
   580     def LoadXMLParams(self, CTNName = None):
   580     def LoadXMLParams(self, CTNName = None):
   581         methode_name = os.path.join(self.CTNPath(CTNName), "methods.py")
   581         methode_name = os.path.join(self.CTNPath(CTNName), "methods.py")
   582         if os.path.isfile(methode_name):
   582         if os.path.isfile(methode_name):
   583             execfile(methode_name)
   583             execfile(methode_name)
   584         
   584         
       
   585         ConfNodeName = CTNName if CTNName is not None else self.CTNName()
       
   586         
   585         # Get the base xml tree
   587         # Get the base xml tree
   586         if self.MandatoryParams:
   588         if self.MandatoryParams:
   587             try:
   589             try:
   588                 basexmlfile = open(self.ConfNodeBaseXmlFilePath(CTNName), 'r')
   590                 basexmlfile = open(self.ConfNodeBaseXmlFilePath(CTNName), 'r')
   589                 self.BaseParams, error = _BaseParamsParser.LoadXMLString(basexmlfile.read())
   591                 self.BaseParams, error = _BaseParamsParser.LoadXMLString(basexmlfile.read())
   590                 if error is not None:
   592                 if error is not None:
   591                     self.GetCTRoot().logger.write_warning(
   593                     self.GetCTRoot().logger.write_warning(
   592                         XSDSchemaErrorMessage % ((CTNName + " BaseParams",) + error))
   594                         XSDSchemaErrorMessage % ((ConfNodeName + " BaseParams",) + error))
   593                 self.MandatoryParams = ("BaseParams", self.BaseParams)
   595                 self.MandatoryParams = ("BaseParams", self.BaseParams)
   594                 basexmlfile.close()
   596                 basexmlfile.close()
   595             except Exception, exc:
   597             except Exception, exc:
   596                 self.GetCTRoot().logger.write_error(_("Couldn't load confnode base parameters %s :\n %s") % (CTNName, unicode(exc)))
   598                 self.GetCTRoot().logger.write_error(_("Couldn't load confnode base parameters %s :\n %s") % (ConfNodeName, unicode(exc)))
   597                 self.GetCTRoot().logger.write_error(traceback.format_exc())
   599                 self.GetCTRoot().logger.write_error(traceback.format_exc())
   598         
   600         
   599         # Get the xml tree
   601         # Get the xml tree
   600         if self.CTNParams:
   602         if self.CTNParams:
   601             try:
   603             try:
   602                 xmlfile = open(self.ConfNodeXmlFilePath(CTNName), 'r')
   604                 xmlfile = open(self.ConfNodeXmlFilePath(CTNName), 'r')
   603                 obj, error = self.Parser.LoadXMLString(xmlfile.read())
   605                 obj, error = self.Parser.LoadXMLString(xmlfile.read())
   604                 if error is not None:
   606                 if error is not None:
   605                     self.GetCTRoot().logger.write_warning(
   607                     self.GetCTRoot().logger.write_warning(
   606                         XSDSchemaErrorMessage % ((CTNName,) + error))
   608                         XSDSchemaErrorMessage % ((ConfNodeName,) + error))
   607                 name = obj.getLocalTag()
   609                 name = obj.getLocalTag()
   608                 setattr(self, name, obj)
   610                 setattr(self, name, obj)
   609                 self.CTNParams = (name, obj)
   611                 self.CTNParams = (name, obj)
   610                 xmlfile.close()
   612                 xmlfile.close()
   611             except Exception, exc:
   613             except Exception, exc:
   612                 self.GetCTRoot().logger.write_error(_("Couldn't load confnode parameters %s :\n %s") % (CTNName, unicode(exc)))
   614                 self.GetCTRoot().logger.write_error(_("Couldn't load confnode parameters %s :\n %s") % (ConfNodeName, unicode(exc)))
   613                 self.GetCTRoot().logger.write_error(traceback.format_exc())
   615                 self.GetCTRoot().logger.write_error(traceback.format_exc())
   614         
   616         
   615     def LoadChildren(self):
   617     def LoadChildren(self):
   616         # Iterate over all CTNName@CTNType in confnode directory, and try to open them
   618         # Iterate over all CTNName@CTNType in confnode directory, and try to open them
   617         for CTNDir in os.listdir(self.CTNPath()):
   619         for CTNDir in os.listdir(self.CTNPath()):