def configureSdCard(): # Our SD card is mounted under E:, so that is where our # binary configuration should be placed. filename = "E:\\PARAM.LIF" xl = kvaMemoLibXml.kvaMemoLibXml() print "kvaMemoLibXml version: v%s" % xl.getVersion() # Convert the previously validated XML configuration file # and write the resulting binary configuration to SD card xl.kvaXmlToFile("config.xml", filename)
def validate(self): result = [] xl = kvaMemoLibXml.kvaMemoLibXml() (countErr, countWarn) = xl.kvaXmlValidate(self.document.toxml()) while countErr > 0: (status, text) = xl.xmlGetValidationError() if status == 0: break result.append(ValidationResult(severity='error', status=status, text=text)) while countWarn > 0: (status, text) = xl.xmlGetValidationWarning() if status == 0: break result.append(ValidationResult(severity='warning', status=status, text=text)) return result
def validate(self): result = [] xl = kvaMemoLibXml.kvaMemoLibXml() (countErr, countWarn) = xl.kvaXmlValidate(self.document.toxml()) while countErr > 0: (status, text) = xl.xmlGetValidationError() if status == 0: break result.append( ValidationResult(severity='error', status=status, text=text)) while countWarn > 0: (status, text) = xl.xmlGetValidationWarning() if status == 0: break result.append( ValidationResult(severity='warning', status=status, text=text)) return result
def toLif(self): xl = kvaMemoLibXml.kvaMemoLibXml() conf_lif = xl.kvaXmlToBuffer(self.document.toxml()) return conf_lif
def parseLif(self, conf_lif): xl = kvaMemoLibXml.kvaMemoLibXml() conf_xml = xl.kvaBufferToXml(conf_lif) self.document = minidom.parseString(conf_xml)
import sys sys.path.append("D:/temp/CanlibSDK_5.14/Samples/Python") import kvaMemoLibXml xl = kvaMemoLibXml.kvaMemoLibXml() print "kvaMemoLibXml version: v" + xl.getVersion() # Read in the XML configuration file with open("config.xml", 'r') as myfile: config_xml = myfile.read() # Validate the XML configuration xl.kvaXmlValidate(config_xml) # Get number of validation messages (countErr, countWarn) = xl.xmlGetValidationStatusCount() print "Errors: %d, Warnings: %d" % (countErr, countWarn) # If we have any validation errors, print those if countErr != 0: code = -1 while code != 0: (code, text) = xl.xmlGetValidationError() print "%d: %s" % (code, text) # If we have any validation warnings, print those if countWarn != 0: code = -1 while code != 0: