Example #1
0
        cpFile = os.path.join(scriptDir, "cp.xsd")
        subprocArgs = "xmllint --noout --schema {0} {1}".format(
            cpFile, xmlfile)
        rc = subprocess.call(subprocArgs, shell=True)
        if rc != 0:
            print >> sys.stderr, "\nERROR - xml xsd validation did not pass"
            sys.exit(2)
        print "\nxml xsd validation passed"
    else:
        # There is no pure python way to easily do this
        print "\nWARNING - skipping xml validation as xmllint is not available on this platform"

    ### Initialize the generated structure ###
    o = xml2objects.ObjectBuilder(xmlfile)

    if not cpvalidate.validate_all(o.root):
        sys.exit(3)

    generated.setControlDeviceData(o.root.controlPanelDevice.name,
                                   o.root.controlPanelDevice.headerCode)
    generated.setLanguageSets(o.root.controlPanelDevice.languageSet)

    ### Get and process HttpControlElements
    if hasattr(o.root.controlPanelDevice, "url"):
        httpControl = http.HttpControl(generated,
                                       o.root.controlPanelDevice.url)
        httpControl.generate()

    ### Get and process all ControlPanels
    if hasattr(o.root.controlPanelDevice, "controlPanels"):
        for cp in o.root.controlPanelDevice.controlPanels.controlPanel:
    if sys.platform != 'win32':
        cpFile = os.path.join(scriptDir, "cp.xsd")
        subprocArgs = "xmllint --noout --schema {0} {1}".format(cpFile, xmlfile)
        rc = subprocess.call(subprocArgs, shell=True)
        if rc != 0 :
            print >> sys.stderr, "\nERROR - xml xsd validation did not pass"
            sys.exit(2)
        print "\nxml xsd validation passed"
    else:
        # There is no pure python way to easily do this
        print "\nWARNING - skipping xml validation as xmllint is not available on this platform"

    ### Initialize the generated structure ###
    o = xml2objects.ObjectBuilder(xmlfile)

    if not cpvalidate.validate_all(o.root):
        print >> sys.stderr, "\nERROR - logic xml validation did not pass"
        sys.exit(3)

    print "\nxml logic validation passed"

    generated.setControlDeviceData(o.root.controlPanelDevice.name, o.root.controlPanelDevice.headerCode)
    generated.setLanguageSets(o.root.controlPanelDevice.languageSet)

    ### Get and process HttpControlElements
    if hasattr(o.root.controlPanelDevice, "url") :
        httpControl = http.HttpControl(generated, o.root.controlPanelDevice.url)
        httpControl.generate()
    
    ### Get and process all ControlPanels
    if hasattr(o.root.controlPanelDevice, "controlPanels") :