Esempio n. 1
0
def main():
    x = 0
    container = Container()
    input_name = str(input())
    output_name = str(input())
    output_filtr_name = str(input())
    try:
        file = open(input_name)
    except ():
        x = 4
    if x != 4:
        x = container.check(file)
        file.close()
    if x == 'x':
        file = open(input_name)
        container.in_data(file)
        file.close()
        container.sort()
        file = open(output_name, "w")
        file1 = open(output_filtr_name, "w")
        container.out(file, x)
        container.out_filtr(file1, x)
        container.clear()
        container.out(file, x)
        container.out_filtr(file1, x)
        file.close()
        file1.close()
    else:
        file = open(output_name, "w")
        file1 = open(output_filtr_name, "w")
        container.out(file, x)
        container.out_filtr(file1, x)
        file.close()
        file1.close()
Esempio n. 2
0
 def fillContainers(self):
     containers = []
     rand = random.randint(1000, self.max_capacity)
     for i in range(rand):
         container = Container(i, None, None, self, self.emptyC)
         containers.append(container)
         self.nr_containers.incrCounter()
     return containers
Esempio n. 3
0
 def generate_containers(self):
     ids = [
         "C" + str(id + 1).zfill(3) for id in range(0, self.containers_num)
     ]
     height = randint(self.containers_min_height,
                      self.containers_max_height)
     for id in ids:
         self.containers.append(
             Container(
                 id,
                 randint(self.containers_min_width,
                         self.containers_max_width),
                 randint(self.containers_min_length,
                         self.containers_max_length), height,
                 SystemRandom().choice(self.timestamps)))
Esempio n. 4
0
 def load_map(self, index):
     game_folder = path.dirname(__file__)
     map_folder = path.join(game_folder, "maps")
     self.map = TileMap(path.join(map_folder, self.map_names[index]))
     self.map_img = self.map.make_map()
     self.map_rect = self.map_img.get_rect()
     self.current_map = index
     self.is_interior = "interior" in self.map_names[self.current_map]
     self.all_sprites = pg.sprite.Group()
     self.walls = pg.sprite.Group()
     self.cell_linkers = pg.sprite.Group()
     self.map_data = [[None for x in range(int(self.map_rect.width / 40))]
                      for i in range(int(self.map_rect.height / 40))]
     # Reading map data
     for tile_object in self.map.tmxdata.objects:
         if tile_object.name == "player":
             self.player = Player(self, tile_object.x, tile_object.y)
         elif tile_object.name == "wall":
             Obstacle(self, tile_object.x, tile_object.y, tile_object.width,
                      tile_object.height)
         elif tile_object.name == "cell_load":
             CellLinker(self, tile_object.x, tile_object.y,
                        tile_object.width, tile_object.height,
                        int(tile_object.properties["cell_link"]), [
                            int(coord) for coord in
                            tile_object.properties["cell_spawn"].split(",")
                        ])
         elif tile_object.name == "chest":
             self.map_data[int(tile_object.y / 40)][int(
                 tile_object.x / 40)] = Container(
                     3, self.drop_tables[
                         tile_object.properties["loot_table"]].get_items(),
                     self.screen, self.player)
             Obstacle(self, tile_object.x, tile_object.y, tile_object.width,
                      tile_object.height)
         try:
             if tile_object.name[:4:] == "npc_":
                 self.map_data[int(tile_object.y / 40)][int(
                     tile_object.x / 40)] = Enemy(self, tile_object.x,
                                                  tile_object.y,
                                                  self.npc1_img,
                                                  tile_object.name[4::])
         except:
             pass
     if self.player not in self.all_sprites:
         self.all_sprites.add(self.player)
Esempio n. 5
0
def create_app() -> FastAPI:


    app = FastAPI()
    app.container = Container()
    config_path = path.join(ROOT_DIR, "config.yaml")
    app.container.config.from_yaml(config_path)
    app.container.wire(modules=[ep])
    # with open(cfg_path, 'r') as stream:
    #     cfg = yaml.load(stream, Loader=yaml.FullLoader)
    # print(cfg)


    frontend=app.container.frontend()
    frontend_t = Thread(target=start_frontend, args=(frontend,), daemon=True)
    frontend_t.start()
    # frontend.run()
    # frontend.async_run(async_lib='trio')
    # trio.run(partial(frontend.async_run, async_lib='trio'))
    # asyncio.create_task(frontend.async_run())
    # loop = asyncio.get_event_loop()
    # loop.run_until_complete(frontend.async_run())

    print("Frontend started")

    # print("Adding middleware....")
    # # app.add_middleware(
    #     CORSMiddleware,
    #     allow_origins=["*"],
    #     allow_credentials=True,
    #     allow_methods=["*"],
    #     allow_headers=["*"],
    # )

    # @app.put("/presence_out_of_bounds/")
    # async def presence_out_of_bounds(am:str=Body(...)):
    #     return frontend.presence_out_of_bounds(am)


    # @app.put("/presence_detected/")
    # async def presence_detected(am:AccessModel):
    #     frontend.presence_detected(am)

    app.include_router(ep.router)

    return app
Esempio n. 6
0
def create_app() -> Flask:
    container = Container()
    container.wire(modules=[controller])
    app = Flask(__name__)
    app.container = container
    app.add_url_rule('/', 'hello', controller.hello)
    app.add_url_rule('/api/picture',
                     'picture',
                     controller.uploadPicture,
                     methods=['POST'])
    app.add_url_rule('/api/zip', 'zip', controller.uploadZip, methods=['POST'])
    app.add_url_rule('/api/thumbnail',
                     'thumbnail',
                     controller.uploadThumbnail,
                     methods=['POST'])
    app.add_url_rule('/api/pic', 'pic', controller.getPicture, methods=['GET'])

    return app
Esempio n. 7
0
def create_app() -> Flask:
    container = Container()
    container.wire(modules=[health.routes])

    app = Flask(__name__)

    app.container = container
    app.config["DEBUG"] = True

    confiuration_service = container.confiuration_service()

    kafka_topic = confiuration_service.get('kafka_consumer_topic')

    container.kafka_listener(
        kafka_topic, confiuration_service.get('kafka_group_id'),
        confiuration_service.get('kafka_advertised_listeners'),
        capture_screenshot)

    app.register_blueprint(health_module)

    app.run()

    return app
Esempio n. 8
0
def create_app() -> FastAPI:
    container = Container()
    container.config.from_yaml('config/config.yaml')
    container.wire(modules=[
        application_controller, environment_controller, variable_controller,
        configuration_controller, change_history_controller, dependencies
    ])

    app = FastAPI(title="Configuration Keeper",
                  description="""This is a project whose main idea 
            is to give developers a single place to store 
            the configurations of their applications with 
            the ability to customize them and then pull 
            them into their projects.""",
                  version="0.3.0",
                  openapi_tags=tags_metadata)
    app.container = container
    app.include_router(application_controller.router)
    app.include_router(environment_controller.router)
    app.include_router(variable_controller.router)
    app.include_router(configuration_controller.router)
    app.include_router(change_history_controller.router)

    return app
import random
from dependency_injector import providers, containers

# import services and classes from other python files
from services import PaymentService, AbstractPayServiceProvider, GoolePayServiceProvider, ApplePayServiceProvider, \
    AliPayServiceProvider
from containers import Container

if __name__ == '__main__':
    container = Container()

    # emulate random choice of payment service provider
    # this could be coming from configuration file
    payment_service_provider = random.choice(['googlepay', 'applepay', 'alipay'])
    if payment_service_provider == 'googlepay':
        container.payment_service_factory.override(
            providers.Factory(GoolePayServiceProvider)
        )
    elif payment_service_provider == 'applepay':
        container.payment_service_factory.override(
            providers.Factory(ApplePayServiceProvider)
        )
    elif payment_service_provider == 'alipay':
        container.payment_service_factory.override(
            providers.Factory(AliPayServiceProvider)
        )

    service = container.service_factory()
    print(service.service_provider_name())
    print(service.payment_service_provider)
Esempio n. 10
0
 def __init__(self, request: Request):
     super().__init__(request)
     self.__limit_service = Container.limit_service(request.app['db'])
Esempio n. 11
0
 def predeath(self):
     self.global_access_variables['container_dict'][str(
         uuid.uuid4())] = Container.Container(self.room,
                                              self.name + ' (dead)')
Esempio n. 12
0
from guides import GuideTut

from PlayerObj import PlayerObj

room_dict = {
    'bedroom': Room.Room('bedroom'),
    'stairs': Room.Room('stairs'),
    'hall': Room.Room('hall'),
    'lounge': Room.Room('lounge'),
    'kitchen': Room.Room('kitchen'),
    'conservatory': Room.Room('conservatory'),
    'heaven': Room.Room('heaven')
}

container_dict = {
    'shelf': Container.Container(room_dict['hall'], 'shelf'),
    'bed': Container.Container(room_dict['bedroom'], 'bed'),
    'table': Container.Container(room_dict['kitchen'], 'table'),
    'cupboards': Container.Container(room_dict['kitchen'], 'cupboards'),
    'body': Container.Container(room_dict['kitchen'], 'corpse'),
    'body_2': Container.Container(room_dict['conservatory'], 'corpse'),
    'safe_kitchen': Safe.Safe(room_dict['kitchen'], 'safe', '256342'),
    'safe_bedroom': Safe.Safe(room_dict['bedroom'], 'bedroom safe', None)
}

exit_dict = {
    'bed-stairs':
    Room.Exit(room_dict['bedroom'], room_dict['stairs'], False),
    'hall-stairs':
    Room.Exit(room_dict['hall'], room_dict['stairs'], False),
    'hall-kitchen':
Esempio n. 13
0
# Built-in modules
import sys
# app modules
from containers import Container
sys.path.append('../')
from budget import create_spend_chart


if __name__ == '__main__':
    container = Container()
    
    food= Container.user_category("Food")
    clothing= Container.user_category("Clothing")
    auto = Container.user_category("Auto")
    
    food.deposit(1000, "initial deposit")
    food.withdraw(10.15, "groceries")
    food.withdraw(15.89, "restaurant and more food for dessert")
    print("Food balance prior transfer: "+str(food.get_balance()))
    food.transfer(50, clothing)
    clothing.withdraw(25.55)
    clothing.withdraw(100)
    auto.deposit(1000, "initial deposit")
    auto.withdraw(15)

    print(food)
    print(clothing)
    print(auto)
    print(create_spend_chart([food, clothing, auto]))
Esempio n. 14
0
            try:
                print('Please, choise object [for exit: Ctr+C]:')
                print('[0] = IMAGE\n[1] = CONTAINER (unactive)')
                obj = objects[int(_input())]

                while True:
                    print(
                        f'Please, choise action for __{obj.__doc__}__ [for exit: Ctr+C]:'
                    )
                    print(f'[0] = info\n'
                          f'[1] = create (unactive)\n'
                          f'[2] = remove')
                    try:
                        action = getattr(obj, actions[int(_input())])
                        action()
                    except (KeyError, KeyboardInterrupt, TypeError):
                        raise ValueError()

            except ValueError as e:
                _print(f'Bad value. Please, repeat input...{e}')
                continue

            except KeyboardInterrupt:
                break


if __name__ == '__main__':
    Image.set_manager(DockerDog)
    Container.set_manager(DockerDog)
    DockerDog.main()
Esempio n. 15
0
    # publish the webhook to subscribers for the following topics
    #  - current wallet id
    #  - topic of the event
    #  - 'all' topic, which allows to subscribe to all published events
    # FIXME: wallet_id is admin for all admin wallets from different origins. We should make a difference on this
    # Maybe the wallet id should be the role (governance, ecosystem-admin, member-admin)?
    await endpoint.publish(
        topics=[topic, redis_item["wallet_id"], WEBHOOK_TOPIC_ALL],
        data=webhook_event.json(),
    )
    # Add data to redis
    await service.add_topic_entry(redis_item["wallet_id"],
                                  json.dumps(redis_item))

    log.debug(f"{topic}:\n{pformat(webhook_event)}")


# Example for broadcasting from eg Redis
# @router.websocket("/pubsub")
# async def websocket_rpc_endpoint(websocket: WebSocket):
#     async with endpoint.broadcaster:
#         await endpoint.main_loop(websocket)

app.include_router(router)

container = RedisContainer()
container.config.redis_host.from_env("REDIS_HOST", "wh-redis")
container.config.redis_password.from_env("REDIS_PASSWORD", "")
container.wire(modules=[sys.modules[__name__]])
Esempio n. 16
0
 def bring_container(self, t):
     #print("lorry brought a container to stack " + str(stack.name))
     container = Container(str(len(self.group.containers)), self.group, None, None, self.emptyC)
     self.group.nr_containers.incrCounter()
     self.group.deliverContainer(container, t)