Esempio n. 1
0
from pdfinvert.wsgi.filter.temporary_file_cleanup_filter import TemporaryFileCleanupFilter


class InvertPdfContext(ProductionJivagoContext):
    LOGGER = logging.getLogger("InvertPdfContext")

    def create_router_config(self) -> RouterBuilder:
        config = super().create_router_config() \
            .add_rule(FilteringRule("*", [TemporaryFileCleanupFilter])) \
            .add_rule(RoutingRule("/static/",
                                  StaticFileRoutingTable(os.path.dirname(static.__file__),
                                                         allowed_extensions=[".png", ".ico", ".html", ".css"])))

        prometheus_endpoint = os.environ.get("PROMETHEUS_GATEWAY_ENDPOINT")
        if prometheus_endpoint:
            InvertPdfContext.LOGGER.info(
                f"Using prometheus pushgateway endpoint {prometheus_endpoint}")
            config.add_rule(FilteringRule("*", [RequestMetricsFilter]))

        return config


logging.getLogger().setLevel(logging.INFO)

application = JivagoApplication(pdfinvert.wsgi, context=InvertPdfContext)

if __name__ == '__main__':
    port = int(os.getenv("PORT", 8080))

    application.run_dev(port=port, host="0.0.0.0")
Esempio n. 2
0
from jivago.jivago_application import JivagoApplication

import hello_world.app

application = JivagoApplication(hello_world.app, debug=False)

if __name__ == '__main__':
    application.run_dev()
Esempio n. 3
0
from jivago.config.router.router_builder import RouterBuilder
from jivago.jivago_application import JivagoApplication
from jivago.wsgi.filter.system_filters.default_filters import JIVAGO_DEFAULT_FILTERS
from jivago.wsgi.routing.routing_rule import RoutingRule
from jivago.wsgi.routing.serving.static_file_routing_table import StaticFileRoutingTable
from jivago.wsgi.routing.table.auto_discovering_routing_table import AutoDiscoveringRoutingTable

anachronos._instance = MessageQueue()


class DemoContext(DebugJivagoContext):
    def configure_service_locator(self):
        super().configure_service_locator()
        self.service_locator().bind(Anachronos, MessageQueue())

    def create_router_config(self) -> RouterBuilder:
        return RouterBuilder() \
            .add_rule(FilteringRule("*", JIVAGO_DEFAULT_FILTERS)) \
            .add_rule(RoutingRule("/api", AutoDiscoveringRoutingTable(self.registry, self.root_package_name))) \
            .add_rule(RoutingRule("/static", StaticFileRoutingTable(os.path.dirname(e2e_test.app.static.__file__),
                                                                    allowed_extensions=['.txt']))) \
            .add_rule(CorsRule("/", {'Access-Control-Allow-Origin': 'http://jivago.io',
                                     'Access-Control-Allow-Headers': '*',
                                     'Access-Control-Allow-Methods': '*'}))


application = JivagoApplication(components, context=DemoContext)

if __name__ == '__main__':
    application.run_dev()
Esempio n. 4
0
                 registry: Registry,
                 banner: bool = True):
        super().__init__(root_package, registry, banner)

    def configure_service_locator(self):
        super().configure_service_locator()

    def scopes(self) -> List[type]:
        return super().scopes()

    def get_views_folder_path(self) -> str:
        return super().get_views_folder_path()

    def get_config_file_locations(self) -> List[str]:
        return super().get_config_file_locations()

    def create_router_config(self) -> RouterBuilder:
        return super().create_router_config()

    def get_default_filters(self):
        return super().get_default_filters()

    def create_event_bus(self) -> EventBus:
        return super().create_event_bus()

    def get_banner(self) -> List[str]:
        return super().get_banner()


app = JivagoApplication(my_package, context=MyApplicationContext)
Esempio n. 5
0
import my_hello_world_application
from jivago.jivago_application import JivagoApplication

app = JivagoApplication(my_hello_world_application)

if __name__ == '__main__':
    app.run_dev()
Esempio n. 6
0
 def app_run_function(self):
     import logging
     logging.getLogger().setLevel(logging.CRITICAL)
     run_wsgi(JivagoApplication(components, context=TestingContext))
Esempio n. 7
0
from jivago.jivago_application import JivagoApplication
from jivago.wsgi.annotations import Resource
from jivago.wsgi.methods import GET


@Resource("/")
class HelloResource(object):
    @GET
    def get_hello(self) -> str:
        return "Hello World!"


app = JivagoApplication()

if __name__ == '__main__':
    app.run_dev()
Esempio n. 8
0
import my_hello_world_application
from jivago.jivago_application import JivagoApplication

app = JivagoApplication(my_hello_world_application)

if __name__ == '__main__':
    from werkzeug.serving import run_simple

    run_simple('localhost', 4000, app)
Esempio n. 9
0
from jivago.lang.annotations import Override

import vision_project
from vision_project.vision.coordinate_converter import CalibratedCoordinateTranslator
from vision_project.vision.coordinate_translator import CoordinateTranslator
from vision_project.vision.image_repository import ImageRepository, SimpleImageRepository


class CameraCaptureContext(DebugJivagoContext):
    @Override
    def configure_service_locator(self):
        super().configure_service_locator()
        repository = SimpleImageRepository()
        self.serviceLocator.bind(ImageRepository, repository)
        self.serviceLocator.bind(CoordinateTranslator,
                                 CalibratedCoordinateTranslator())

    @Override
    def get_config_file_locations(self) -> List[str]:
        return [
            os.path.join(str(Path.home()), "vision.yml"),
            os.path.join(os.path.dirname(vision_project.__file__),
                         "vision.yml"), "vision.yml"
        ]


app = JivagoApplication(vision_project, context=CameraCaptureContext)

if __name__ == "__main__":
    app.run_dev(host="0.0.0.0")
Esempio n. 10
0
import logging

import example_app
from jivago.jivago_application import JivagoApplication

if __name__ == '__main__':
    logging.getLogger().setLevel(logging.INFO)
    app = JivagoApplication(example_app, debug=True)
    app.run_dev()
Esempio n. 11
0
import os

from jivago.jivago_application import JivagoApplication

import pdfinvert.wsgi

application = JivagoApplication(pdfinvert.wsgi)

if __name__ == '__main__':
    port = int(os.getenv("PORT", 8080))

    application.run_dev(port=port, host="0.0.0.0")
Esempio n. 12
0
import logging
import os

import example_app.static
from jivago.config.production_jivago_context import ProductionJivagoContext
from jivago.jivago_application import JivagoApplication
from jivago.lang.annotations import Override
from jivago.lang.registry import Registry
from jivago.wsgi.routing.router import Router
from jivago.wsgi.routing.serving.static_file_routing_table import StaticFileRoutingTable


class ExampleStaticServingContext(ProductionJivagoContext):

    @Override
    def create_router(self) -> Router:
        router = super().create_router()
        router.add_routing_table(StaticFileRoutingTable(os.path.dirname(example_app.static.__file__)), "/static")
        return router


if __name__ == '__main__':
    logging.getLogger().setLevel(logging.INFO)
    app = JivagoApplication(example_app, context=ExampleStaticServingContext(example_app, Registry.INSTANCE))
    app.run_dev()
Esempio n. 13
0
from jivago.jivago_application import JivagoApplication

app = JivagoApplication()

if __name__ == '__main__':
    # using the bundled werkzeug server
    app.run_dev(port=4000, host="localhost")

    # or alternatively
    from werkzeug.serving import run_simple

    run_simple('localhost', 4000, app)
Esempio n. 14
0
import logging

from jivago.jivago_application import JivagoApplication
from jivago.lang.registry import Registry

import prismarine
from prismarine.infrastructure.config.prismarine_context import PrismarineContext

logging.getLogger().setLevel(logging.INFO)
app = JivagoApplication(prismarine,
                        context=PrismarineContext(prismarine, Registry()))

if __name__ == '__main__':
    app.run_dev(host='0.0.0.0', port=4000)
Esempio n. 15
0
from jivago.jivago_application import JivagoApplication

import poll_bot.app

application = JivagoApplication(poll_bot.app)

if __name__ == '__main__':
    application.run_dev()