예제 #1
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)
예제 #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
    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)