コード例 #1
0
ファイル: features.py プロジェクト: Zealsathish/ovirt-node
def launch_bottle(registry):
    import bottle

    # Create a bottle instance and register some routes
    app = bottle.Bottle()

    xmlbuilder = XmlBuilder()
    xmlbuilder.xslt_url = "/featured.xsl"

    @app.route(xmlbuilder.xslt_url)
    def xslt():
        bottle.response.headers['Content-Type'] = 'application/xml'
        fn = os.path.dirname(__file__) + "/featured.xsl"
        print fn, __file__
        with open(fn) as src:
            return src.read()

    @app.route("/")
    def index():
        """Show the complete registry
        """
        bottle.response.headers['Content-Type'] = 'application/xml'
        return xmlbuilder.build(registry)

    @app.route("/methods/<path:path>")
    def call_method(path):
        """Call some method offered by the registry
        """
        bottle.response.headers['Content-Type'] = 'application/xml'
        kwargs = dict(bottle.request.query.items())
        return xmlbuilder.build(registry.methods[path](**kwargs))

    bottle.run(app, host='0.0.0.0', port=8082, reloader=True, debug=True)
コード例 #2
0
def launch_bottle(registry):
    import bottle

    # Create a bottle instance and register some routes
    app = bottle.Bottle()

    xmlbuilder = XmlBuilder()
    xmlbuilder.xslt_url = "/featured.xsl"

    @app.route(xmlbuilder.xslt_url)
    def xslt():
        bottle.response.headers['Content-Type'] = 'application/xml'
        fn = os.path.dirname(__file__) + "/featured.xsl"
        print fn, __file__
        with open(fn) as src:
            return src.read()

    @app.route("/")
    def index():
        """Show the complete registry
        """
        bottle.response.headers['Content-Type'] = 'application/xml'
        return xmlbuilder.build(registry)

    @app.route("/methods/<path:path>")
    def call_method(path):
        """Call some method offered by the registry
        """
        bottle.response.headers['Content-Type'] = 'application/xml'
        kwargs = dict(bottle.request.query.items())
        return xmlbuilder.build(registry.methods[path](**kwargs))

    bottle.run(app, host='0.0.0.0', port=8082, reloader=True, debug=True)
コード例 #3
0
ファイル: features.py プロジェクト: Zealsathish/ovirt-node
    value = SystemRelease().cpe()


if __name__ == "__main__":
    # Create a feature registry
    registry = Registry()

    # Statically register a feature which represents the version
    registry.register(CpeProperty(owner=Owner(name=__name__)))

    # Now go through all plugins and see if they want to publish sth too
    groups = loader.plugin_groups_iterator(setup, "createPluginFeatures")
    for group, createPluginFeatures in groups:
        if createPluginFeatures:
            logging.info("Registering feature from %s" % group)
            createPluginFeatures(registry)

    # The registry is now build time to publish it

    if "-d" in sys.argv:
        # Via a http daemon
        launch_bottle(registry)
    elif "dumpxml" in sys.argv:
        # In XML to stdout
        xmlbuilder = XmlBuilder()
        print(xmlbuilder.build(registry))
    else:
        print("Get a feature summary about this node.")
        print("Usage: %s [dumpxml]" % sys.argv[0])
        sys.exit(1)
コード例 #4
0
    value = SystemRelease().cpe()


if __name__ == "__main__":
    # Create a feature registry
    registry = Registry()

    # Statically register a feature which represents the version
    registry.register(CpeProperty(owner=Owner(name=__name__)))

    # Now go through all plugins and see if they want to publish sth too
    groups = loader.plugin_groups_iterator(setup, "createPluginFeatures")
    for group, createPluginFeatures in groups:
        if createPluginFeatures:
            logging.info("Registering feature from %s" % group)
            createPluginFeatures(registry)

    # The registry is now build time to publish it

    if "-d" in sys.argv:
        # Via a http daemon
        launch_bottle(registry)
    elif "dumpxml" in sys.argv:
        # In XML to stdout
        xmlbuilder = XmlBuilder()
        print(xmlbuilder.build(registry))
    else:
        print("Get a feature summary about this node.")
        print("Usage: %s [-d] [dumpxml]" % sys.argv[0])
        sys.exit(1)