def xml_read(self, hardwareObjectName, path): if self.server.hardwareRepositoryDirectory is not None: filename = os.path.normpath(self.server.hardwareRepositoryDirectory + hardwareObjectName + '.xml') if os.path.exists(filename): try: ret = SimpleXMLReadWriteSupport.read(filename, path) except SAXParseException, msg: return { '__error__': 'Could not parse hardware object file %s : %s' % (hardwareObjectName, msg) } except: return { '__error__': 'Could not read hardware object %s' % hardwareObjectName }
def xml_read(self, hardwareObjectName, path): if self.server.hardwareRepositoryDirectory is not None: filename = os.path.normpath( self.server.hardwareRepositoryDirectory + hardwareObjectName + ".xml") if os.path.exists(filename): try: ret = SimpleXMLReadWriteSupport.read(filename, path) except SAXParseException as msg: return { "__error__": "Could not parse hardware object file %s : %s" % (hardwareObjectName, msg) } except BaseException: return { "__error__": "Could not read hardware object %s" % hardwareObjectName } # # format return value for Spec # spec_ret = {} for i in range(len(ret)): dict = {} dict.update(ret[i]) tmp = "" if "__children__" in dict: for childpath, childname in list( dict["__children__"].items()): tmp += childname + ":" + childpath + " " tmp.strip() dict["__children__"] = tmp spec_ret[i] = dict if len(spec_ret) > 0: return spec_ret else: return {"__error__": "No match."} else: return {"__error__": "%s does not exist." % hardwareObjectName} else: return {"__error__": "No server."}
def xml_read(self, hardwareObjectName, path): if self.server.hardwareRepositoryDirectory is not None: filename = os.path.normpath( self.server.hardwareRepositoryDirectory + hardwareObjectName + '.xml') if os.path.exists(filename): try: ret = SimpleXMLReadWriteSupport.read(filename, path) except SAXParseException as msg: return { '__error__': 'Could not parse hardware object file %s : %s' % (hardwareObjectName, msg) } except: return { '__error__': 'Could not read hardware object %s' % hardwareObjectName } # # format return value for Spec # spec_ret = {} for i in range(len(ret)): dict = {} dict.update(ret[i]) tmp = '' if '__children__' in dict: for childpath, childname in list( dict['__children__'].items()): tmp += childname + ':' + childpath + ' ' tmp.strip() dict['__children__'] = tmp spec_ret[i] = dict if len(spec_ret) > 0: return spec_ret else: return {'__error__': 'No match.'} else: return {'__error__': '%s does not exist.' % hardwareObjectName} else: return {'__error__': 'No server.'}
def xml_read(self, hardwareObjectName, path): if self.server.hardwareRepositoryDirectory is not None: filename = os.path.normpath( self.server.hardwareRepositoryDirectory + hardwareObjectName + '.xml') if os.path.exists(filename): try: ret = SimpleXMLReadWriteSupport.read(filename, path) except SAXParseException, msg: return { '__error__': 'Could not parse hardware object file %s : %s' % (hardwareObjectName, msg) } except: return {
def xml_read(self, hardwareObjectName, path): if self.server.hardwareRepositoryDirectory is not None: filename = os.path.normpath( self.server.hardwareRepositoryDirectory + hardwareObjectName + ".xml" ) if os.path.exists(filename): try: ret = SimpleXMLReadWriteSupport.read(filename, path) except SAXParseException as msg: return { "__error__": "Could not parse hardware object file %s : %s" % (hardwareObjectName, msg) } except BaseException: return { "__error__": "Could not read hardware object %s" % hardwareObjectName } # # format return value for Spec # spec_ret = {} for i in range(len(ret)): dict = {} dict.update(ret[i]) tmp = "" if "__children__" in dict: for childpath, childname in list(dict["__children__"].items()): tmp += childname + ":" + childpath + " " tmp.strip() dict["__children__"] = tmp spec_ret[i] = dict if len(spec_ret) > 0: return spec_ret else: return {"__error__": "No match."} else: return {"__error__": "%s does not exist." % hardwareObjectName} else: return {"__error__": "No server."}
def xml_read(self, hardwareObjectName, path): if self.server.hardwareRepositoryDirectory is not None: filename = os.path.normpath(self.server.hardwareRepositoryDirectory + hardwareObjectName + '.xml') if os.path.exists(filename): try: ret = SimpleXMLReadWriteSupport.read(filename, path) except SAXParseException as msg: return { '__error__': 'Could not parse hardware object file %s : %s' % (hardwareObjectName, msg) } except: return { '__error__': 'Could not read hardware object %s' % hardwareObjectName } # # format return value for Spec # spec_ret = {} for i in range(len(ret)): dict = {} dict.update(ret[i]) tmp = '' if '__children__' in dict: for childpath, childname in list(dict['__children__'].items()): tmp += childname + ':' + childpath + ' ' tmp.strip() dict['__children__'] = tmp spec_ret[i]=dict if len(spec_ret) > 0: return spec_ret else: return { '__error__': 'No match.' } else: return { '__error__': '%s does not exist.' % hardwareObjectName } else: return { '__error__': 'No server.' }