async def initialize():
        with open(Path(__file__).parents[2] / 'conf' / 'default.yml',
                  'r') as fle:
            BaseWorld.apply_config('main', yaml.safe_load(fle))
        with open(Path(__file__).parents[2] / 'conf' / 'payloads.yml',
                  'r') as fle:
            BaseWorld.apply_config('payloads', yaml.safe_load(fle))

        app_svc = AppService(web.Application())
        _ = DataService()
        _ = RestService()
        _ = PlanningService()
        _ = LearningService()
        auth_svc = AuthService()
        _ = ContactService()
        _ = FileSvc()
        services = app_svc.get_services()
        os.chdir(str(Path(__file__).parents[2]))

        await app_svc.register_contacts()
        await app_svc.load_plugins(['sandcat', 'ssl'])
        _ = await RestApi(services).enable()
        await auth_svc.apply(app_svc.application, auth_svc.get_config('users'))
        await auth_svc.set_login_handlers(services)
        return app_svc.application
Exemple #2
0
 def initialize(self):
     self.app_svc = AppService(None)
     self.data_svc = DataService()
     self.rest_svc = RestService()
     self.planning_svc = PlanningService()
     self.learning_svc = LearningService()
     self.services = [self.app_svc.get_services()]
Exemple #3
0
    async def initialize():
        with open(Path(__file__).parents[1] / 'conf' / 'default.yml',
                  'r') as fle:
            BaseWorld.apply_config('main', yaml.safe_load(fle))
        with open(Path(__file__).parents[1] / 'conf' / 'payloads.yml',
                  'r') as fle:
            BaseWorld.apply_config('payloads', yaml.safe_load(fle))

        app_svc = AppService(web.Application(client_max_size=5120**2))
        _ = DataService()
        _ = RestService()
        _ = PlanningService()
        _ = LearningService()
        auth_svc = AuthService()
        _ = FileSvc()
        _ = EventService()
        services = app_svc.get_services()
        os.chdir(str(Path(__file__).parents[1]))

        _ = await RestApi(services).enable()
        await app_svc.register_contacts()
        await auth_svc.apply(app_svc.application, auth_svc.get_config('users'))
        await auth_svc.set_login_handlers(services)

        app_svc.register_subapp('/api/v2', make_app(svcs=services))
        aiohttp_apispec.setup_aiohttp_apispec(app=app_svc.application,
                                              title='CALDERA',
                                              version=version.get_version(),
                                              swagger_path='/api/docs',
                                              url='/api/docs/swagger.json',
                                              static_path='/static/swagger')
        app_svc.application.middlewares.append(
            apispec_request_validation_middleware)
        app_svc.application.middlewares.append(validation_middleware)

        return app_svc
Exemple #4
0
    parser = argparse.ArgumentParser('Welcome to the system')
    parser.add_argument('-E',
                        '--environment',
                        required=False,
                        default='local',
                        help='Select an env. file to use')
    parser.add_argument('--fresh',
                        action='store_true',
                        required=False,
                        default=False,
                        help='remove object_store on start')
    args = parser.parse_args()
    config = args.environment if pathlib.Path(
        'conf/%s.yml' % args.environment).exists() else 'default'
    with open('conf/%s.yml' % config) as c:
        BaseWorld.apply_config(yaml.load(c, Loader=yaml.FullLoader))
        data_svc = DataService()
        contact_svc = ContactService(
            BaseWorld.strip_yml('conf/agents.yml')[0]['agent_config'])
        planning_svc = PlanningService()
        rest_svc = RestService()
        auth_svc = AuthService()
        file_svc = FileSvc(
            BaseWorld.strip_yml('conf/payloads.yml')[0]['payload_config'])
        learning_svc = LearningService()
        app_svc = AppService(application=web.Application())

        if args.fresh:
            asyncio.get_event_loop().run_until_complete(data_svc.destroy())
        run_tasks(services=app_svc.get_services())
Exemple #5
0
def learning_svc():
    return LearningService()